html, body {
    height: 100dvh;
    overflow: hidden;
}

.login-shell {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(280px, .8fr) minmax(500px, 1.2fr);
    grid-template-rows: minmax(0, 1fr);
}

.welcome-panel {
    position: relative;
    display: flex;
    min-height: 100%;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: clamp(28px, 5vw, 70px);
    color: #fffaf2;
    background: var(--coffee);
}

.welcome-panel::after {
    position: absolute;
    right: -110px;
    bottom: -100px;
    width: 330px;
    height: 330px;
    border: 55px solid rgba(255, 255, 255, .045);
    border-radius: 50%;
    content: "";
}

.brand {
    position: relative;
    z-index: 1;
    width: fit-content;
}

.welcome-copy {
    position: relative;
    z-index: 1;
    max-width: 520px;
}

.eyebrow,
.step-label {
    margin: 0 0 12px;
    color: #d9a58f;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.welcome-copy h1 {
    margin: 0;
    font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
    font-size: clamp(3.1rem, 6.5vw, 6.5rem);
    font-weight: 500;
    letter-spacing: -.055em;
    line-height: .9;
}

.welcome-copy>p:last-child {
    margin: 28px 0 0;
    color: #d9cdc5;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
}

.sheep-scene {
    position: relative;
    z-index: 1;
    width: min(100%, 430px);
    height: 180px;
    margin: 26px 0 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 250, 242, .18);
    border-radius: 24px;
    background: linear-gradient(180deg, #f4e7d7 0 68%, #c9d4ad 68% 100%);
    box-shadow: inset 0 -18px 32px rgba(59, 41, 35, .08);
}

.sheep {
    position: absolute;
    z-index: 3;
    width: 86px;
    height: 62px;
    transform-origin: center bottom;
}

.sheep-body {
    position: absolute;
    top: 9px;
    left: 3px;
    width: 64px;
    height: 43px;
    border-radius: 48% 52% 44% 46%;
    background: #fffaf2;
    box-shadow:
        -8px 3px 0 -1px #fffaf2,
        5px -7px 0 -2px #fffaf2,
        14px 4px 0 -3px #fffaf2;
}

.sheep-head {
    position: absolute;
    top: 19px;
    right: 2px;
    width: 31px;
    height: 34px;
    border-radius: 50% 55% 48% 45%;
    background: #2b201d;
}

.sheep-head::before,
.sheep-head::after {
    position: absolute;
    top: -4px;
    width: 15px;
    height: 9px;
    border-radius: 80% 15%;
    background: #2b201d;
    content: "";
}

.sheep-head::before { left: -8px; transform: rotate(24deg); }
.sheep-head::after { right: -7px; transform: scaleX(-1) rotate(24deg); }

.sheep-head i {
    position: absolute;
    top: 10px;
    right: 7px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fffaf2;
    box-shadow: 0 0 0 2px #2b201d;
    animation: sheep-blink 4.5s infinite;
}

.sheep-leg {
    position: absolute;
    bottom: 0;
    width: 6px;
    height: 18px;
    border-radius: 0 0 4px 4px;
    background: #2b201d;
}

.leg-one { left: 21px; }
.leg-two { left: 55px; }
.sheep-waiting { left: 40px; bottom: 21px; animation: sheep-breathe 2.7s ease-in-out infinite; }
.sheep-jumping { right: 73px; bottom: 55px; animation: sheep-jump 4.2s cubic-bezier(.45, 0, .2, 1) infinite; }

.fence {
    position: absolute;
    z-index: 2;
    right: 77px;
    bottom: 15px;
    width: 86px;
    height: 59px;
}

.fence span {
    position: absolute;
    bottom: 0;
    width: 9px;
    height: 58px;
    border-radius: 4px 4px 1px 1px;
    background: #b8845b;
}

.fence span:nth-child(1) { left: 8px; }
.fence span:nth-child(2) { right: 8px; }
.fence span:nth-child(3) {
    top: 21px;
    left: 0;
    width: 86px;
    height: 9px;
    transform: rotate(-2deg);
}

.scene-note {
    position: absolute;
    right: 16px;
    bottom: 8px;
    z-index: 4;
    margin: 0;
    color: rgba(59, 41, 35, .68);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
}

@keyframes sheep-jump {
    0%, 16%, 100% { transform: translate(0, 32px) rotate(0); }
    42% { transform: translate(-17px, -18px) rotate(-7deg); }
    62% { transform: translate(-34px, 12px) rotate(4deg); }
    72% { transform: translate(-34px, 32px) rotate(0); }
}

@keyframes sheep-breathe {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes sheep-blink {
    0%, 45%, 49%, 100% { transform: scaleY(1); }
    47% { transform: scaleY(.15); }
}

.help-text {
    position: relative;
    z-index: 1;
    margin: 0;
    color: #b9aaa2;
    font-size: .9rem;
}

.welcome-footer {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 36px;
}

.access-panel {
    display: grid;
    place-items: start center;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: max(14px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.access-panel::-webkit-scrollbar {
    width: 10px;
}

.access-panel::-webkit-scrollbar-track {
    background: #eee4d7;
}

.access-panel::-webkit-scrollbar-thumb {
    border: 2px solid #eee4d7;
    border-radius: 999px;
    background: #9f8c7f;
}

.access-card {
    width: min(100%, 470px);
    margin-block: auto;
}

.login-chat-alert {
    position: absolute; z-index: 6; top: clamp(24px, 4vw, 54px); right: clamp(24px, 4vw, 54px);
    display: flex; max-width: 230px; align-items: center; gap: 9px;
    border: 1px solid rgba(255,250,242,.14); border-radius: 13px; padding: 8px 10px;
    color: #fffaf2; background: rgba(255,250,242,.075);
    box-shadow: 0 8px 24px rgba(20,12,10,.14); backdrop-filter: blur(8px);
    animation: login-chat-pulse 2.4s ease-in-out infinite;
}
.login-chat-alert[hidden] { display: none; }
.login-chat-alert img { width: 25px; height: 25px; filter: brightness(0) invert(1); opacity: .86; }
.login-chat-alert span { display: grid; }
.login-chat-alert strong { font-size: .7rem; }
.login-chat-alert small { color: #cbbdb5; font-size: .6rem; }
@keyframes login-chat-pulse {
    0%, 100% { opacity: .82; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .login-chat-alert { animation: none; } }

.access-card header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 8px;
}

.step-label {
    color: var(--terracotta);
}

.access-card h2 {
    margin: 0;
    font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 500;
    letter-spacing: -.035em;
}

.alert {
    margin: -2px 0 8px;
    padding: 0;
    border: 0;
    color: #8a7b72;
    background: transparent;
    font-size: .76rem;
    font-weight: 550;
    line-height: 1.35;
}

form {
    display: grid;
}

label {
    margin: 0 0 8px;
    font-size: .9rem;
    font-weight: 750;
}

label[for="pin"] {
    margin-top: 7px;
    margin-bottom: 5px;
}

.location-picker,
.user-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.location-picker {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5ddd4;
}

.location-picker legend,
.user-picker legend {
    margin: 0 0 6px;
    padding: 0;
    font-size: .9rem;
    font-weight: 750;
}

.location-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.location-grid label {
    display: grid;
    gap: 3px;
    margin: 0;
    color: #655a54;
    font-size: .76rem;
}

.location-grid select {
    width: 100%;
    min-height: 42px;
    padding: 0 38px 0 13px;
    border: 1px solid #d8cec5;
    border-radius: 12px;
    color: var(--coffee);
    background: #fffaf4;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
}

.location-grid select:focus-visible {
    border-color: var(--terracotta);
    outline: 3px solid rgba(193, 93, 67, .16);
}

.location-summary,
.empty-users {
    margin: 5px 0 0;
    color: #786b63;
    font-size: .78rem;
}

.empty-users {
    padding: 14px;
    border-radius: 12px;
    background: #f6eee5;
    text-align: center;
}

.user-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.user-option {
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 72px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    border: 2px solid var(--line);
    border-radius: 15px;
    color: var(--coffee);
    background: var(--paper);
    cursor: pointer;
    touch-action: manipulation;
}

.user-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    opacity: 0;
}

.user-avatar {
    display: grid;
    width: 32px;
    height: 32px;
    overflow: hidden;
    place-items: center;
    border-radius: 50%;
    color: var(--terracotta-dark);
    background: #f3e2d7;
    font-size: 1.05rem;
    font-weight: 850;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-option .check {
    position: absolute;
    top: 7px;
    right: 8px;
    display: none;
    color: var(--focus);
    font-size: 1rem;
}

.user-option:has(input:checked) {
    border-color: var(--focus);
    background: #fff3ed;
    box-shadow: 0 0 0 3px rgba(158, 69, 45, .12);
}

.user-option:has(input:checked) .user-avatar {
    color: white;
    background: var(--focus);
}

.user-option:has(input:checked) .check {
    display: block;
}

.user-option:has(input:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.other-users {
    margin-top: 6px;
    border-top: 1px solid #e5ddd4;
}

.other-users summary {
    display: flex;
    min-height: 34px;
    align-items: center;
    gap: 8px;
    color: #786b63;
    cursor: pointer;
    font-size: .76rem;
    font-weight: 750;
    list-style: none;
}

.other-users summary::-webkit-details-marker {
    display: none;
}

.other-users summary small {
    display: grid;
    min-width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 999px;
    color: #786b63;
    background: #eee4d8;
    font-size: .65rem;
}

.other-users summary i {
    width: 7px;
    height: 7px;
    margin-left: auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .18s;
}

.other-users[open] summary i {
    transform: rotate(225deg);
}

.user-grid--secondary {
    padding: 2px 0 10px;
}

.user-grid--secondary .user-option {
    min-height: 78px;
    border-width: 1px;
    background: #fbf6ef;
}

.user-grid--secondary .user-avatar {
    width: 34px;
    height: 34px;
}

input {
    width: 100%;
    min-height: 50px;
    border: 2px solid var(--line);
    border-radius: 14px;
    outline: none;
    color: var(--coffee);
    background: var(--paper);
    padding: 0 18px;
    font-size: 1.25rem;
    font-weight: 700;
    transition: border-color .18s, box-shadow .18s;
}

input:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 4px rgba(158, 69, 45, .14);
}

input::placeholder {
    color: #ad9f96;
    font-weight: 500;
}

.pin-field {
    position: relative;
}

.pin-field input {
    padding-right: 116px;
    letter-spacing: .25em;
}

.toggle-keypad,
.show-pin {
    position: absolute;
    top: 6px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 10px;
    color: var(--muted);
    background: transparent;
}

.toggle-keypad {
    right: 56px;
    font-size: 1.35rem;
}

.show-pin {
    top: 1px;
    right: 3px;
    height: 48px;
}

.toggle-keypad[aria-expanded="true"] {
    color: var(--terracotta-dark);
    background: #f3e8dc;
}

.toggle-keypad:focus-visible,
.show-pin:focus-visible {
    outline: 3px solid var(--focus);
}

.eye {
    display: inline-block;
    width: 23px;
    height: 15px;
    border: 2px solid currentColor;
    border-radius: 70% 10%;
    transform: rotate(45deg);
}

.eye::after {
    display: block;
    width: 5px;
    height: 5px;
    margin: 3px auto;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.keypad {
    display: grid;
    width: min(100%, 270px);
    grid-template-columns: repeat(3, 1fr);
    gap: 9px 10px;
    margin: 12px auto 2px;
}

.keypad[hidden] {
    display: none;
}

.keypad button {
    min-height: 0;
    aspect-ratio: 1.55;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: var(--coffee);
    background: var(--paper);
    box-shadow: 0 3px 0 #cfc0b1;
    font-size: 1.22rem;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
}

.keypad button:active {
    transform: translateY(2px);
    box-shadow: none;
    background: #eee4d8;
}

.keypad button:focus-visible,
.submit-button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.keypad .clear-key,
.keypad .delete-key {
    color: var(--terracotta-dark);
    background: #f3e8dc;
}

.submit-button {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    margin-top: 7px;
    border: 0;
    border-radius: 15px;
    padding: 0 22px;
    color: white;
    background: var(--terracotta);
    box-shadow: 0 5px 0 var(--terracotta-dark);
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
}

.submit-button:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--terracotta-dark);
}

.submit-button span {
    font-size: 1.6rem;
}

.refresh-button,
.lock-button {
    position: relative;
    display: grid;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    aspect-ratio: 1;
    flex: 0 0 auto;
    align-items: center;
    place-items: center;
    border: 0;
    border-radius: 50%;
    padding: 0;
    color: rgba(255, 250, 242, .48);
    background: transparent;
    font-size: 1rem;
    cursor: pointer;
    opacity: .65;
    transition: color .18s, background .18s, opacity .18s;
}

.login-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 26px;
    padding: 3px 10px 20px;
}

.refresh-button > span {
    line-height: 1;
}

.refresh-button.is-loading .refresh-icon {
    animation: refresh-spin .75s linear infinite;
}

@keyframes refresh-spin {
    to {
        transform: rotate(1turn);
    }
}

@media (prefers-reduced-motion: reduce) {
    .refresh-button.is-loading .refresh-icon {
        animation-duration: 1.5s;
    }
}

.login-actions .action-label {
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    width: max-content;
    padding: 0;
    color: rgba(255, 250, 242, .55);
    background: transparent;
    font-size: .58rem;
    font-weight: 650;
    line-height: 1.35;
    pointer-events: none;
    transform: translateX(-50%);
}

.refresh-button:hover,
.lock-button:hover {
    color: #fffaf2;
    background: rgba(255, 250, 242, .09);
    opacity: 1;
}

.refresh-button:focus-visible,
.lock-button:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.refresh-button:disabled,
.lock-button:disabled {
    cursor: wait;
    opacity: .55;
}

.lock-icon {
    position: relative;
    width: 14px;
    height: 12px;
    margin-top: 3px;
    border: 2px solid currentColor;
    border-radius: 3px;
}

.lock-icon::before {
    position: absolute;
    bottom: 8px;
    left: 1px;
    width: 8px;
    height: 8px;
    border: 2px solid currentColor;
    border-bottom: 0;
    border-radius: 7px 7px 0 0;
    content: "";
}

.lock-status {
    margin: -4px 0 12px;
    padding: 9px 11px;
    border-radius: 9px;
    color: #7e2e1d;
    background: #fff0ea;
    font-size: .82rem;
    font-weight: 650;
}

.refresh-status {
    margin: -4px 0 12px;
    padding: 9px 11px;
    border-radius: 9px;
    color: #655a54;
    background: #f3e8dc;
    font-size: .82rem;
    font-weight: 650;
}

.refresh-status--error {
    color: #7e2e1d;
    background: #fff0ea;
}

@media (max-width: 760px) {
    .login-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .welcome-panel {
        min-height: auto;
        padding: 22px 24px;
    }

    .login-chat-alert {
        top: auto; right: auto; bottom: 10px; left: 24px;
        max-width: 190px; padding: 6px 9px;
    }

    .welcome-copy {
        display: none;
    }

    .sheep-scene {
        position: absolute;
        right: 20px;
        bottom: 13px;
        width: 128px;
        height: 55px;
        margin: 0;
        border-radius: 14px;
    }

    .sheep-scene .sheep-waiting,
    .sheep-scene .scene-note {
        display: none;
    }

    .sheep-jumping {
        right: 43px;
        bottom: 4px;
        transform: scale(.55);
        animation: none;
    }

    .fence {
        right: 10px;
        bottom: -4px;
        transform: scale(.55);
    }

    .help-text {
        display: none;
    }

    .welcome-footer {
        position: absolute;
        top: 18px;
        right: 20px;
        margin: 0;
    }

    .brand img {
        width: 130px;
    }

    .access-panel {
        align-items: start;
        padding-top: 28px;
    }

    .access-card header {
        margin-bottom: 18px;
    }
}

@media (max-height: 850px) and (min-width: 761px) {
    .welcome-copy h1 {
        font-size: 4rem;
    }

    .sheep-scene {
        height: 135px;
        margin-block: 12px 0;
    }

    .access-panel {
        padding-block: 10px;
    }

    .access-card header {
        margin-bottom: 6px;
    }

    .access-card h2 {
        font-size: 2rem;
    }

    .step-label {
        margin-bottom: 4px;
    }

    .location-picker {
        margin-bottom: 8px;
        padding-bottom: 7px;
    }

    .location-picker legend,
    .user-picker legend {
        margin-bottom: 5px;
    }

    .location-grid label {
        gap: 3px;
    }

    .location-grid select {
        min-height: 40px;
    }

    .location-summary {
        margin-top: 5px;
    }

    .user-option {
        min-height: 62px;
        gap: 2px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
    }

    input {
        min-height: 44px;
    }

    label[for="pin"] {
        margin-top: 6px;
        margin-bottom: 4px;
    }

    .show-pin {
        top: 0;
        height: 44px;
    }

    .keypad {
        width: min(100%, 250px);
        gap: 6px 7px;
        margin-top: 7px;
    }

    .keypad button {
        min-height: 0;
        aspect-ratio: 1.8;
        border-radius: 13px;
        font-size: 1.05rem;
    }

    .submit-button {
        min-height: 42px;
        margin-top: 7px;
    }
}
