/*
 * SecondBrain - the one stylesheet of the web app.
 *
 * Look and feel (docs/PRODUCT.md): English only, calm and clean, light, one accent
 * colour, generous white space, desktop browser first.
 *
 * Every page is rendered into templates/layout.php, so header, navigation, cards,
 * tables and messages look the same everywhere.
 */

:root {
    --accent: #2f5fd0;
    --accent-strong: #23479e;
    --accent-soft: #eef3fd;
    --ink: #1c2430;
    --ink-muted: #5d6b7a;
    --line: #e2e8f0;
    --surface: #ffffff;
    --background: #f7f9fc;
    --warning-soft: #fdf6e6;
    --warning-line: #e8c98a;
    --danger: #b4322c;
    --radius: 10px;
    --radius-small: 6px;
    --space: 1rem;
    --shadow: 0 1px 2px rgba(28, 36, 48, 0.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--ink);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    margin: 0 0 0.35em;
    line-height: 1.25;
    font-weight: 600;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.15rem;
}

p {
    margin: 0 0 0.75em;
}

p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

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

.container {
    width: 100%;
    max-width: 62rem;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.muted {
    color: var(--ink-muted);
}

.hint {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    z-index: 10;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
}

/* ---------------------------------------------------------------- header ---- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    min-height: 4rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--ink);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand:hover {
    color: var(--ink);
    text-decoration: none;
}

.brand__mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='7' width='14' height='3' rx='1.5' fill='white'/%3E%3Crect x='5' y='13' width='9' height='3' rx='1.5' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

.brand__name {
    font-size: 1.05rem;
}

.site-nav__list {
    display: flex;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__link {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-small);
    color: var(--ink-muted);
    font-weight: 500;
}

.site-nav__link:hover {
    color: var(--ink);
    background: var(--background);
    text-decoration: none;
}

.site-nav__link.is-active {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

/* ------------------------------------------------------------------ page ---- */

.page {
    flex: 1 0 auto;
    padding-top: 2.5rem;
    padding-bottom: 4rem;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.75rem;
}

.page-head__text .lead {
    margin: 0;
    color: var(--ink-muted);
}

.page-head__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    flex-shrink: 0;
    max-width: 20rem;
}

.page-head__actions .hint {
    flex-basis: 100%;
    text-align: right;
}

.breadcrumb {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: var(--ink-muted);
}

.breadcrumb span[aria-hidden] {
    margin: 0 0.35rem;
    color: var(--line);
}

/* ----------------------------------------------------------------- cards ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card > h2 {
    margin-bottom: 0.75rem;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
}

/* ---------------------------------------------------------------- tables ---- */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table th,
.table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.table thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
    background: var(--background);
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: var(--accent-soft);
}

.table__number {
    text-align: right;
}

/* ---------------------------------------------------------------- badges ---- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge--private {
    color: var(--ink-muted);
    background: var(--background);
    border: 1px solid var(--line);
}

.badge--shared {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 1px solid #c9d8f7;
}

/* --------------------------------------------------------------- buttons ---- */

.button {
    display: inline-block;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
}

.button:hover {
    border-color: #cbd5e1;
    text-decoration: none;
}

.button--primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.button--primary:hover {
    border-color: var(--accent-strong);
    background: var(--accent-strong);
    color: #fff;
}

.button--danger {
    color: var(--danger);
    border-color: #e7c9c7;
}

.button--small {
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
}

.button[disabled],
.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---------------------------------------------------------------- forms ----- */

.field {
    display: block;
    margin-bottom: 1rem;
}

.field__label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.field__input {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    font: inherit;
    color: var(--ink);
}

.field__input:disabled {
    background: var(--background);
    color: var(--ink-muted);
}

.filter,
.ask-form,
.settings-form {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.filter .field {
    margin-bottom: 0;
}

.ask-form__actions,
.settings-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.option-list {
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.option {
    padding: 0.35rem 0;
}

.option__label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* ------------------------------------------------------------- details ------ */

.details {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.4rem 1rem;
    margin: 0;
}

.details dt {
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.details dd {
    margin: 0;
}

.email-body {
    margin: 0;
    padding: 1rem;
    background: var(--background);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 32rem;
    overflow: auto;
}

.attachment-list {
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.attachment {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
}

.attachment:last-child {
    border-bottom: 0;
}

.attachment__name {
    font-weight: 500;
}

/* ------------------------------------------------------------- messages ----- */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-small);
    margin-bottom: 1.5rem;
}

.alert--warning {
    background: var(--warning-soft);
    border: 1px solid var(--warning-line);
}

/* ------------------------------------------------------------------ chat ----- */
/*
 * The Ask page is a messenger (docs/PRODUCT.md, section 3): the earlier conversations
 * are the sidebar (.chat__sidebar), the scope chooser is in the header, the conversation
 * is the thread (the agent on the left, the owner's own questions on the right) and the
 * question box is a composer at the bottom. While the agent writes an answer it shows
 * three dots (.typing). The thread and the sidebar are filled from the conversations and
 * chat_exchanges tables (E59, E60, E64).
 */

.chat {
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.chat__head-text h1 {
    margin-bottom: 0.15rem;
}

.chat__head-text .lead {
    margin: 0;
    color: var(--ink-muted);
}

.chat__scope {
    flex-shrink: 0;
}

.chat__scope-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
}

.chat__select {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    font: inherit;
    color: var(--ink);
}

.chat__select:disabled {
    background: var(--background);
    color: var(--ink-muted);
}

.chat__thread {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.5rem;
    min-height: 17rem;
    max-height: 32rem;
    overflow-y: auto;
    background: var(--background);
}

.chat__msg {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    max-width: 42rem;
}

.chat__msg--agent {
    align-self: flex-start;
}

.chat__msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat__bubble {
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.chat__bubble p:last-child {
    margin-bottom: 0;
}

.chat__msg--user .chat__bubble {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.chat__bubble--typing {
    padding: 0.75rem 0.95rem;
}

.chat__note {
    margin: 0;
    font-size: 0.85rem;
}

/* three dots while the agent is typing */
.typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-muted);
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing__dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing__dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }

    30% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .typing__dot {
        animation: none;
        opacity: 0.75;
    }
}

.chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
}

.chat__input {
    flex: 1;
    min-height: 2.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    font: inherit;
    color: var(--ink);
    resize: vertical;
}

.chat__input:disabled {
    background: var(--background);
    color: var(--ink-muted);
}

.chat__quick {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.5rem 0.25rem;
}

.chat__quick-label {
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.chat__hint {
    padding: 0.5rem 1.5rem 1.25rem;
    margin: 0;
}

.chip {
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.chip:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.chip[disabled],
.chip:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* --------------------------------------------------------------- footer ----- */

.site-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.site-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 3.5rem;
    font-size: 0.85rem;
}

/* ------------------------------------------------------------ narrow view --- */

@media (max-width: 720px) {
    .site-header__inner,
    .page-head,
    .chat__head,
    .site-footer__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .chat__composer {
        flex-direction: column;
        align-items: stretch;
    }

    .page-head__actions .hint {
        text-align: left;
    }

    .details {
        grid-template-columns: 1fr;
    }

    .table th,
    .table td {
        padding: 0.6rem 0.7rem;
    }
}

/* ------------------------------------------------- Release 1.0 additions ----- */
/*
 * The pieces the cards of Release 1.0 added to pages that already existed: the filter
 * box, the question before a delete, the flash line with Undo, the "New project" card,
 * the conversations beside the chat, and the sources under an answer.
 */

.alert--ok {
    background: #eaf6ee;
    border: 1px solid #a8d5b5;
}

.flash {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    margin-bottom: 1.5rem;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
}

.flash__text {
    font-weight: 500;
}

.flash__action {
    margin: 0;
}

.confirm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--warning-soft);
    border: 1px solid var(--warning-line);
    border-radius: var(--radius-small);
}

.confirm__question {
    flex: 1 1 18rem;
    margin: 0;
    font-weight: 500;
}

.form-card {
    margin-bottom: 1.5rem;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin: 0;
}

.inline-form--tight {
    gap: 0.4rem;
    align-items: center;
}

.inline-form .field {
    flex: 1 1 16rem;
}

.inline-form__actions {
    display: flex;
    gap: 0.5rem;
}

.filter {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.filter .field {
    flex: 0 1 22rem;
}

.table__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-end;
}

.table__question td {
    background: var(--background);
}

.chat__sidebar {
    border-right: 1px solid var(--line);
    background: var(--background);
    padding: 1rem 0.75rem;
    min-width: 0;
}

.chat__sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.chat__sidebar-title {
    margin: 0;
    font-size: 1rem;
}

.chat__sidebar-empty {
    margin: 0;
    padding: 0.25rem 0;
}

.conversation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.conversation__link {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-small);
    color: var(--ink);
    text-decoration: none;
    border: 1px solid transparent;
}

.conversation__link:hover {
    background: var(--surface);
    border-color: var(--line);
}

.conversation.is-current .conversation__link {
    background: var(--surface);
    border-color: var(--accent);
}

.conversation__title {
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.conversation__date {
    font-size: 0.75rem;
}

.chat__more {
    display: block;
    margin-top: 0.6rem;
    text-align: center;
}

.chat__main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sources {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
}

.sources__title {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-muted);
}

.sources__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.source {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.source__subject {
    font-weight: 500;
}

.source__meta {
    font-size: 0.8rem;
}

.chat__copy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.6rem 0 0;
}

.chat__copied {
    font-size: 0.85rem;
    color: var(--ink-muted);
}

@media (max-width: 900px) {
    .chat {
        grid-template-columns: 1fr;
    }

    .chat__sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
}

/* ------------------------------------------------------------ sign-in area ---- */
/*
 * The sign-in pages (E70) use their own shell (templates/layout-auth.php): a two-column
 * page at desktop width - what the product is, beside the card - and one column on a
 * phone, the card first in reading order after the hero.
 */

.auth-body {
    background: #eef1ef;
}

.site-header--auth .brand {
    color: var(--ink);
}

.site-header--auth .brand:hover {
    text-decoration: none;
}

.pill--signed-out {
    font-size: 0.75rem;
    font-weight: 600;
    color: #0b5f58;
    background: #e3f1ee;
    border: 1px solid #bfe0da;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    white-space: nowrap;
}

.auth-page {
    max-width: 67.5rem;
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 26rem;
    gap: 3.5rem;
    align-items: start;
}

.auth-hero .eyebrow {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #0b5f58;
}

.auth-hero h1 {
    margin: 0;
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    max-width: 15em;
}

.auth-hero .lead {
    margin: 1.1rem 0 0;
    font-size: 0.95rem;
    color: var(--ink-muted);
    max-width: 38em;
}

.auth-facts {
    list-style: none;
    margin: 1.75rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.85rem;
    max-width: 34em;
}

.auth-facts li {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    font-size: 0.875rem;
    color: #3b4a46;
}

.auth-facts li::before {
    content: "✓";
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #e3f1ee;
    border: 1px solid #bfe0da;
    color: #0b5f58;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.auth-card {
    padding: 2rem;
}

.auth-card h2 {
    font-size: 1.5rem;
}

.auth-card .muted {
    margin: 0.5rem 0 1.5rem;
    font-size: 0.875rem;
}

.auth-card--wide {
    grid-column: auto;
}

.auth-form .field {
    margin-bottom: 1rem;
}

.auth-submit {
    width: 100%;
    min-height: 3rem;
    margin-top: 0.35rem;
    font-size: 1rem;
}

.auth-card__foot {
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--line);
}

.auth-card__foot p {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    color: var(--ink-muted);
}

.auth-topline {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: -2rem;
}

.auth-account {
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.link-button {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.auth-steps {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #0b5f58;
}

.auth-card--wide {
    grid-column: 1 / -1;
    justify-self: center;
    width: 100%;
    max-width: 46rem;
}

.auth-lede {
    margin: 0.5rem 0 1.5rem;
    color: var(--ink-muted);
    font-size: 0.9rem;
}

.auth-notice {
    margin-bottom: 1rem;
}

.two-factor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: start;
}

.qr svg {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    background: #fff;
}

.manual-key {
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.manual-key code {
    font-family: var(--font-mono);
    word-break: break-all;
    color: var(--ink);
}

.two-factor-form .auth-step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.9rem 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.auth-step__number {
    flex: none;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: #0b5f58;
    background: #e3f1ee;
    border: 1px solid #bfe0da;
}

.field__input--code {
    font-family: var(--font-mono);
    letter-spacing: 0.35em;
    font-size: 1.2rem;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin: 0.75rem 0;
}

.check input {
    margin-top: 0.15rem;
    flex: none;
}

.check__hint {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-soft, #6b7873);
    margin-top: 0.1rem;
}

.recovery {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    padding-top: 1.25rem;
    margin-top: 1.5rem;
}

.recovery h3 {
    font-size: 0.95rem;
}

.recovery-list {
    list-style: none;
    margin: 0.75rem 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: 0.5rem;
}

.recovery-list code {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    padding: 0.4rem 0.6rem;
    text-align: center;
}

.auth-card .lead {
    font-size: 0.95rem;
    color: var(--ink-muted);
}

.auth-card .details {
    margin-bottom: 1.25rem;
}

@media (max-width: 880px) {
    .auth-page {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
        padding-top: 2rem;
        padding-bottom: 2.75rem;
    }

    .auth-card {
        max-width: 27.5rem;
        width: 100%;
        margin: 0 auto;
    }

    .auth-hero h1,
    .auth-hero .lead,
    .auth-facts {
        max-width: none;
    }

    .auth-topline,
    .auth-steps {
        margin-bottom: 0;
    }

    .two-factor-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.25rem;
    }
}

@media (max-width: 620px) {
    .auth-page {
        padding: 1.6rem 1rem 2.5rem;
    }

    .auth-card {
        padding: 1.5rem 1.25rem;
        border-radius: 12px;
    }

    .auth-card h2 {
        font-size: 1.35rem;
    }

    .auth-facts li {
        font-size: 0.84rem;
    }
}

/* ------------------------------------------------- Release 1.1 - people ------ */
/*
 * The Users page (E72): the table of accounts, the role and status badges, the
 * one-time link box, the two-factor switch and the security log.
 */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
}

.users-table {
    min-width: 46rem;
}

.users-table__email {
    font-weight: 500;
}

.users-table__note {
    display: block;
    font-size: 0.8rem;
}

.users-table__role {
    margin-top: 0.35rem;
}

.badge--admin {
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 1px solid #c9d8f7;
}

.badge--user {
    color: var(--ink-muted);
    background: var(--background);
    border: 1px solid var(--line);
}

.badge--active {
    color: #256b3b;
    background: #eaf6ee;
    border: 1px solid #a8d5b5;
}

.badge--disabled {
    color: var(--ink-muted);
    background: var(--background);
    border: 1px solid var(--line);
}

.badge--locked {
    color: var(--danger);
    background: #fbeceb;
    border: 1px solid #e7b4b0;
}

.link-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius-small);
    overflow-x: auto;
}

.link-box a {
    flex: 1 1 18rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    word-break: break-all;
}

.switch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 0.4rem;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch__track {
    position: relative;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 1.4rem;
    border-radius: 999px;
    background: var(--line);
    transition: background 0.15s ease;
}

.switch__track::after {
    content: "";
    position: absolute;
    top: 0.2rem;
    left: 0.2rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.switch input:checked + .switch__track {
    background: var(--accent);
}

.switch input:checked + .switch__track::after {
    transform: translateX(1.1rem);
}

.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.switch__label {
    font-weight: 500;
}

.security-log {
    list-style: none;
    margin: 0.5rem 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
}

.security-log li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line);
}

.security-log li:last-child {
    border-bottom: 0;
}

.security-log__message {
    flex: 1 1 18rem;
}

.security-log__date {
    font-size: 0.85rem;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .users-table {
        min-width: 40rem;
    }

    .table__actions {
        justify-content: flex-start;
    }
}

.chat__scope-hint {
    margin-top: 0.4rem;
    max-width: 22rem;
    font-size: 0.8rem;
}

@media (max-width: 620px) {
    .chat__scope-hint {
        max-width: none;
    }
}
