:root {
    --auth-paper: #f7f5f0;
    --auth-paper-deep: #ece8df;
    --auth-ink: #292524;
    --auth-muted: #786f66;
    --auth-rule: #d8d0c5;
    --auth-vermilion: #a9342b;
    --auth-yellow: #d6a31d;
    --auth-night: #24211e;
}

.auth-body {
    min-height: 100vh;
    margin: 0;
    background: var(--auth-paper);
    color: var(--auth-ink);
}

.auth-nav {
    position: relative;
    z-index: 40;
    border-bottom: 1px solid var(--auth-rule);
    background: rgba(247, 245, 240, 0.92);
    backdrop-filter: blur(12px);
}

.account-layout {
    min-height: calc(100vh - 61px);
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(25rem, 0.92fr);
}

.account-intro,
.account-entry {
    min-width: 0;
    padding: clamp(2.5rem, 6vw, 6.5rem);
}

.account-intro {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--auth-paper-deep);
    background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(73, 63, 54, 0.045) 32px);
}

.account-intro::after {
    content: '';
    position: absolute;
    top: 0;
    right: 1.6rem;
    bottom: 0;
    border-right: 1px dashed rgba(80, 69, 59, 0.22);
    pointer-events: none;
}

.account-back {
    width: fit-content;
    color: var(--auth-muted);
    font-size: 0.78rem;
    text-decoration: none;
    transition: color 160ms ease;
}

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

.archive-heading {
    max-width: 38rem;
    margin: auto 0;
    padding: 4rem 0;
}

.archive-kicker,
.entry-number,
.archive-code {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.69rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.archive-kicker { color: var(--auth-vermilion); }

.archive-heading h1 {
    margin: 1.15rem 0 1.4rem;
    color: var(--auth-ink);
    font-family: 'Noto Serif SC', 'SimSun', 'STSong', serif;
    font-size: clamp(3.25rem, 7vw, 6.7rem);
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: 0;
}

.archive-heading h1 span {
    display: block;
    color: var(--auth-vermilion);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.48em;
    font-style: italic;
    font-weight: 400;
    line-height: 1.1;
}

.archive-lead {
    max-width: 31rem;
    margin: 0;
    color: #554d46;
    font-size: 1rem;
    line-height: 2;
    text-wrap: pretty;
}

.access-ledger {
    max-width: 34rem;
    margin: 0;
    border-top: 1px solid rgba(80, 69, 59, 0.24);
}

.access-ledger > div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(80, 69, 59, 0.16);
}

.access-ledger dt { color: #514941; font-size: 0.84rem; }
.access-ledger dd { margin: 0; color: var(--auth-vermilion); font-size: 0.84rem; font-weight: 700; }

.archive-signature {
    display: flex;
    align-items: center;
    align-self: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    color: #514941;
    transform: rotate(-4deg);
}

.archive-code { color: inherit; letter-spacing: 0.12em; }
.archive-line { width: 3.5rem; border-top: 1px solid currentColor; }
.archive-seal {
    display: grid;
    width: 3.25rem;
    height: 3.25rem;
    place-items: center;
    border: 2px solid var(--auth-vermilion);
    border-radius: 50%;
    color: var(--auth-vermilion);
    font-family: 'STKaiti', 'KaiTi', serif;
    font-size: 1.35rem;
}

.account-entry {
    display: grid;
    align-items: center;
    background: #ffffff;
}

.account-form-wrap,
.account-signed-in {
    width: min(100%, 28rem);
    margin: 0 auto;
    animation: account-enter 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes account-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.entry-heading { margin-bottom: 2rem; }
.entry-number { color: var(--auth-vermilion); }
.entry-heading h2,
.account-signed-in h2 {
    margin: 0.75rem 0 0.55rem;
    color: var(--auth-ink);
    font-family: 'Noto Serif SC', 'SimSun', 'STSong', serif;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.2;
    letter-spacing: 0;
}

.account-signed-in h2 {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: clamp(1.65rem, 3vw, 2.6rem);
}

.entry-heading p:last-child,
.account-signed-in > p {
    color: var(--auth-muted);
    font-size: 0.875rem;
    line-height: 1.8;
    text-wrap: pretty;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--auth-rule);
}

.auth-tab {
    position: relative;
    border: 0;
    background: transparent;
    padding: 0.75rem 0;
    color: #968d84;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
}

.auth-tab::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: transparent;
}

.auth-tab.is-active { color: var(--auth-ink); font-weight: 700; }
.auth-tab.is-active::after { background: var(--auth-yellow); }

.auth-form { display: grid; gap: 1.1rem; }
.auth-field { display: grid; gap: 0.45rem; }
.auth-field.hidden { display: none; }
.auth-field label { color: #4f4943; font-size: 0.8rem; font-weight: 700; }
.auth-field input {
    width: 100%;
    min-height: 3.35rem;
    border: 1px solid #cfc7bd;
    border-radius: 3px;
    outline: 0;
    background: #fbfaf8;
    padding: 0.75rem 0.9rem;
    color: var(--auth-ink);
    font: inherit;
    font-size: 0.9rem;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.auth-field input::placeholder { color: #aaa198; }
.auth-field input:focus {
    border-color: var(--auth-yellow);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(214, 163, 29, 0.15);
}

.auth-submit {
    display: inline-flex;
    min-height: 3.35rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--auth-night);
    border-radius: 3px;
    background: var(--auth-night);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 160ms ease, transform 160ms ease;
}

.auth-submit:hover { background: #3a3530; transform: translateY(-1px); }
.auth-submit:disabled { cursor: wait; opacity: 0.58; transform: none; }
.auth-submit:focus-visible,
.auth-logout:focus-visible,
.auth-tab:focus-visible,
.browse-without-login:focus-visible,
.account-back:focus-visible {
    outline: 2px solid var(--auth-yellow);
    outline-offset: 3px;
}

.auth-message { margin: 0; font-size: 0.8rem; line-height: 1.6; }
.auth-message-error { color: #a62922; }
.auth-message-success { color: #2d6d51; }

.browse-without-login {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    border-top: 1px solid #e6e0d8;
    padding-top: 1.15rem;
    color: var(--auth-muted);
    font-size: 0.8rem;
    text-decoration: none;
}

.browse-without-login:hover { color: var(--auth-ink); }

.account-signed-in { position: relative; }
.signed-in-mark {
    width: fit-content;
    margin: 2.5rem 0 1.75rem;
    border: 2px solid var(--auth-vermilion);
    padding: 0.38rem 0.65rem;
    color: var(--auth-vermilion);
    font-family: 'STKaiti', 'KaiTi', serif;
    font-size: 1.05rem;
    transform: rotate(-3deg);
}
.signed-in-label { margin: 0; }
.account-continue { width: 100%; margin-top: 2rem; }
.auth-logout {
    width: 100%;
    min-height: 3rem;
    margin-top: 0.65rem;
    border: 0;
    background: transparent;
    color: var(--auth-muted);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
}
.auth-logout:hover { color: var(--auth-vermilion); }

html.dark .auth-body { background: #181614; color: #ece6de; }
html.dark .auth-nav { border-color: #3d3630; background: rgba(24, 22, 20, 0.92); }
html.dark .account-intro {
    background-color: #211e1b;
    background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(255, 255, 255, 0.035) 32px);
}
html.dark .account-intro::after { border-color: rgba(255, 255, 255, 0.12); }
html.dark .archive-signature { color: #b6aca2; }
html.dark .archive-heading h1,
html.dark .entry-heading h2,
html.dark .account-signed-in h2 { color: #f0ebe5; }
html.dark .archive-lead,
html.dark .access-ledger dt { color: #b6aca2; }
html.dark .access-ledger { border-color: #494039; }
html.dark .access-ledger > div { border-color: #3d3630; }
html.dark .account-entry { background: #181614; }
html.dark .auth-tabs { border-color: #3d3630; }
html.dark .auth-tab.is-active { color: #ece6de; }
html.dark .auth-field label { color: #cfc5ba; }
html.dark .auth-field input { border-color: #4e463f; background: #24211e; color: #ece6de; }
html.dark .auth-field input:focus { border-color: #d6a31d; background: #292521; }
html.dark .auth-submit { border-color: #e3b52e; background: #e3b52e; color: #221f1c; }
html.dark .auth-submit:hover { background: #f0c441; }
html.dark .browse-without-login { border-color: #3d3630; }

@media (max-width: 820px) {
    .account-layout { grid-template-columns: 1fr; }
    .account-intro,
    .account-entry { padding: 2rem 1.25rem; }
    .account-intro { min-height: auto; }
    .account-intro::after { display: none; }
    .archive-heading { margin: 3.5rem 0 2.5rem; padding: 0; }
    .archive-heading h1 { font-size: clamp(3.3rem, 17vw, 5.2rem); }
    .archive-lead { max-width: 28rem; }
    .access-ledger { margin-bottom: 1.5rem; }
    .archive-signature { margin-top: 0.5rem; }
    .account-entry { min-height: 35rem; border-top: 1px solid var(--auth-rule); }
}

@media (max-width: 480px) {
    .auth-nav .max-w-6xl { padding-top: 0.65rem; padding-bottom: 0.65rem; }
    .account-intro { padding-bottom: 1.5rem; }
    .archive-heading { margin-top: 2.75rem; }
    .archive-heading h1 { margin-bottom: 1rem; }
    .archive-lead { font-size: 0.92rem; line-height: 1.85; }
    .archive-signature { display: none; }
    .account-entry { min-height: 32rem; padding-top: 3rem; padding-bottom: 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .account-form-wrap,
    .account-signed-in { animation: none; }
}
