:root {
    --bg: #f3f4f2;
    --surface: #ffffff;
    --surface-2: #fafaf8;
    --ink: #2a2a28;
    --ink-2: #55564f;
    --ink-3: #8a8b83;
    --line: #e5e5e0;
    --line-2: #ededea;
    --accent: #b98a2c;
    --accent-soft: #f4ebd6;
    --accent-ink: #6f5416;
    --danger: #b85450;
    --danger-soft: #f8e8e6;
    --danger-ink: #8d3b38;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-1: 0 1px 0 rgba(20, 20, 18, .02), 0 2px 8px rgba(20, 20, 18, .04);
    --shadow-2: 0 1px 0 rgba(20, 20, 18, .03), 0 18px 44px rgba(20, 20, 18, .09);
    --font-sans: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: grid;
    place-items: center;
    padding: 40px 20px;
}

a {
    color: var(--accent-ink);
}

a:hover {
    color: #8d6a1e;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(1100px 520px at 50% -8%, rgba(185, 138, 44, .09), transparent 70%),
        repeating-linear-gradient(135deg, rgba(42, 42, 40, .022) 0 1px, transparent 1px 14px);
}

.auth {
    position: relative;
    width: 100%;
    max-width: 420px;
    animation: rise .4s ease both;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
}

.brand .logo {
    width: 140px;
    height: 96px;
    object-fit: contain;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    padding: 28px 26px 24px;
}

.card h1 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.card .sub {
    color: var(--ink-3);
    font-size: 13px;
    margin-bottom: 22px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 7px;
}

.input-wrap {
    position: relative;
}

.input-wrap > svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--ink-3);
    stroke-width: 1.7;
    fill: none;
    pointer-events: none;
    transition: stroke .15s;
}

.control {
    width: 100%;
    height: 44px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.control::placeholder {
    color: var(--ink-3);
}

/* Keep browser/password-manager autofill consistent with the template. */
.control:autofill,
.control:-webkit-autofill,
.control:-webkit-autofill:hover {
    -webkit-text-fill-color: var(--ink);
    caret-color: var(--ink);
    box-shadow: 0 0 0 1000px var(--surface-2) inset;
    -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset;
}

.control:autofill:focus,
.control:-webkit-autofill:focus,
.control:-webkit-autofill:active {
    -webkit-text-fill-color: var(--ink);
    caret-color: var(--ink);
    box-shadow:
        0 0 0 1000px var(--surface) inset,
        0 0 0 3px rgba(185, 138, 44, .13);
    -webkit-box-shadow:
        0 0 0 1000px var(--surface) inset,
        0 0 0 3px rgba(185, 138, 44, .13);
}

.control:hover {
    border-color: #d8d8d2;
}

.control:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(185, 138, 44, .13);
}

.input-wrap:focus-within > svg {
    stroke: var(--accent-ink);
}

.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--ink-3);
}

.pw-toggle:hover {
    background: var(--surface-2);
    color: var(--ink-2);
}

.pw-toggle svg {
    width: 16px;
    height: 16px;
    stroke-width: 1.7;
    fill: none;
}

.control.pw {
    padding-right: 42px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 4px 0 20px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-2);
}

.check input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.check .box {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    display: grid;
    place-items: center;
    transition: background .15s, border-color .15s;
}

.check .box svg {
    width: 11px;
    height: 11px;
    stroke: #fff;
    stroke-width: 2.6;
    fill: none;
    opacity: 0;
    transform: scale(.6);
    transition: opacity .12s, transform .12s;
}

.check input:checked + .box {
    background: var(--accent);
    border-color: var(--accent);
}

.check input:checked + .box svg {
    opacity: 1;
    transform: scale(1);
}

.check input:focus-visible + .box {
    box-shadow: 0 0 0 3px rgba(185, 138, 44, .22);
}

.row a {
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.row a:hover {
    text-decoration: underline;
}

.btn {
    width: 100%;
    height: 46px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: background .15s, transform .1s;
}

.btn:hover {
    background: #a67c26;
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    fill: none;
}

.btn.loading {
    pointer-events: none;
    background: #c8a35a;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: none;
}

.btn.loading .spinner {
    display: block;
}

.btn.loading .btn-txt {
    opacity: .85;
}

.btn.loading .btn-ico {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.alert {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows .26s cubic-bezier(.4, 0, .2, 1), opacity .2s;
    margin-bottom: 0;
}

.alert.show {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-bottom: 18px;
}

.alert-in {
    overflow: hidden;
}

.alert-body {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 12px 13px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    border: 1px solid #eccdc9;
    color: var(--danger-ink);
}

.alert-body .ai {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.alert-body .ai svg {
    width: 18px;
    height: 18px;
    stroke: var(--danger);
    stroke-width: 1.9;
    fill: none;
}

.alert-body .at {
    font-size: 13px;
    line-height: 1.45;
}

.alert-body .at b {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.alert-body .at .tries {
    font-family: var(--font-mono);
    font-size: 11px;
    opacity: .85;
    margin-top: 4px;
}

.card.shake {
    animation: shake .42s cubic-bezier(.36, .07, .19, .97);
}

@keyframes shake {
    10%,
    90% {
        transform: translateX(-2px);
    }
    20%,
    80% {
        transform: translateX(4px);
    }
    30%,
    50%,
    70% {
        transform: translateX(-7px);
    }
    40%,
    60% {
        transform: translateX(7px);
    }
}

.control.invalid {
    border-color: var(--danger);
    background: #fdf7f6;
}

.control.invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(184, 84, 80, .14);
}

.input-wrap.invalid > svg {
    stroke: var(--danger);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card.shake,
    .auth {
        animation: none;
    }
}
