*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --white: #ffffff;
    --ink: #111010;
    --ink-faint: #c0bbb0;
    --ink-mid: #7a756a;
    --dot-off: #e8e4dc;
    --bar-height: 44px;
}

html,
body {
    height: 100%;
}

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--white);
    color: var(--ink);
    font-family: "EB Garamond", Georgia, serif;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 180px 180px;
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

.nav-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: env(safe-area-inset-top, 0px) 2rem 0;
    height: calc(var(--bar-height) + env(safe-area-inset-top, 0px));
    background-color: var(--white);
}

.nav-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: "DM Mono", monospace;
    font-size: 0.6rem;
    font-weight: 300;
    letter-spacing: 0.2em;
    color: var(--ink-mid);
    text-decoration: none;
    transition: color 0.2s ease;
}
.nav-back:hover {
    color: var(--ink);
}

.stage {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.4rem;
    padding: 2rem;
    opacity: 0;
    transform: translateY(12px);
    animation: fadeUp 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.contact-header {
    text-align: center;
}

.quote-rule {
    width: 32px;
    height: 1px;
    background: var(--ink-faint);
    margin: 1.5rem auto 0;
}

.contact-title {
    font-family: "EB Garamond", Georgia, serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(1.4rem, 4vw, 2rem);
    color: var(--ink);
    letter-spacing: 0.01em;
}

.contact-form {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.contact-fields {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.contact-fields[hidden] {
    display: none;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-field label {
    font-family: "DM Mono", monospace;
    font-size: 0.58rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-mid);
}

.contact-identity {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.identity-signin {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: 1px solid var(--dot-off);
    border-radius: 999px;
    padding: 0.6rem 1.2rem;
    font-family: "DM Mono", monospace;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    color: var(--ink-mid);
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        color 0.2s ease;
}
.identity-signin:hover {
    border-color: var(--ink-mid);
    color: var(--ink);
}
.identity-signin[hidden] {
    display: none;
}

.identity-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}
.identity-user[hidden] {
    display: none;
}
.identity-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--dot-off);
    background: var(--dot-off);
}
.identity-name {
    font-family: "DM Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.form-field input,
.form-field textarea {
    font-family: "EB Garamond", Georgia, serif;
    font-size: 1rem;
    color: var(--ink);
    background: var(--dot-off);
    border: none;
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    transition: outline-color 0.2s ease;
}
.form-field input:focus,
.form-field textarea:focus {
    outline: 2px solid var(--ink-mid);
    outline-offset: 1px;
}
.form-field textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.contact-send {
    align-self: center;
    margin-top: 0.4rem;
    background: none;
    border: 1px solid var(--ink-mid);
    border-radius: 999px;
    padding: 0.7rem 2.2rem;
    font-family: "DM Mono", monospace;
    font-size: 0.6rem;
    font-weight: 300;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}
.contact-send:hover {
    background: var(--ink);
    color: var(--white);
}

.auth-status {
    text-align: center;
    font-family: "DM Mono", monospace;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
    min-height: 1em;
}

.form-status {
    text-align: center;
    font-family: "DM Mono", monospace;
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    color: var(--ink-mid);
    min-height: 1em;
}

.footer {
    position: sticky;
    bottom: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem env(safe-area-inset-bottom, 0px);
    height: calc(var(--bar-height) + env(safe-area-inset-bottom, 0px));
    background-color: var(--white);
}

.footer-center {
    font-family: "DM Mono", monospace;
    font-size: 0.55rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--ink-mid);
    white-space: nowrap;
}

@media (max-width: 480px) {
    .contact-form {
        max-width: 100%;
    }
    .footer-center {
        font-size: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stage {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
