/* ==========================================================================
   Auth pages skin — login / signup / forgot / reset / verify / 2FA / account.
   Loaded via {% block head_extra %} AFTER tokens.css, styles(.mobile).css and
   components.css, so equal-specificity rules here win the cascade.

   All colors come from tokens.css. The single deliberate exception is the
   QR backing card (#fff) so the code stays scannable in dark mode.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Page shell — center a single card on the page background.
   Desktop <main> is overflow:hidden flex column, so the container is the
   scroller; on mobile it participates in normal flow.
   -------------------------------------------------------------------------- */
.auth-container,
.auth-mobile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;
    gap: 0;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    padding: 32px 16px 48px;
    background: var(--bg-page);
    box-sizing: border-box;
}

.mobile-main .auth-container,
.mobile-main .auth-mobile-container {
    min-height: calc(100vh - var(--header-height, 60px));
    min-height: calc(100dvh - var(--header-height, 60px));
    padding: 14px;
}

/* --------------------------------------------------------------------------
   The card
   -------------------------------------------------------------------------- */
.auth-box,
.auth-mobile-box,
.auth-mobile-welcome {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-modal);
    box-shadow: var(--shadow-modal);
    padding: 30px 28px 26px;
    box-sizing: border-box;
    text-align: left;
}

.auth-card--wide {
    max-width: 470px;
}

.auth-mobile-welcome {
    max-width: 440px;
    text-align: center;
}

.mobile-main .auth-box,
.mobile-main .auth-mobile-box,
.mobile-main .auth-mobile-welcome {
    padding: 24px 18px 20px;
}

/* --------------------------------------------------------------------------
   Brand header: logo + title on top
   -------------------------------------------------------------------------- */
.auth-box .auth-logo,
.auth-mobile-box .auth-logo {
    display: block;
    width: 56px;
    height: 56px;
    max-width: 56px;
    max-height: 56px;
    margin: 0 auto 12px;
}

.auth-box h2,
.auth-mobile-box h2 {
    margin: 0 0 18px;
    text-align: center;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.auth-description {
    text-align: center;
    color: var(--ink-secondary);
    font-size: 13.5px;
    line-height: 1.55;
    margin: -8px 0 18px;
}

/* Mobile login brand block */
.auth-mobile-brand {
    text-align: center;
    margin-bottom: 18px;
}

.auth-mobile-brand .auth-logo {
    margin: 0 auto 8px;
}

.auth-mobile-brand h1 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.auth-mobile-brand .tagline {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-tertiary);
}

/* --------------------------------------------------------------------------
   Form fields — section-label style labels, token inputs
   -------------------------------------------------------------------------- */
.auth-box .form-group,
.auth-mobile-box .form-group {
    margin: 0 0 14px;
    width: 100%;
    box-sizing: border-box;
}

.auth-box .form-group label,
.auth-mobile-box .form-group label {
    display: block;
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-secondary);
    text-align: left;
}

.auth-box input:not([type="checkbox"]):not([type="radio"]),
.auth-mobile-box input:not([type="checkbox"]):not([type="radio"]),
.auth-box select,
.auth-mobile-box select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 15px;
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
}

/* Keep 16px on real mobile to prevent iOS zoom-on-focus */
.mobile-main .auth-box input:not([type="checkbox"]):not([type="radio"]),
.mobile-main .auth-mobile-box input:not([type="checkbox"]):not([type="radio"]) {
    font-size: 16px;
}

/* --------------------------------------------------------------------------
   Actions — full-width accent submit, stacked links
   -------------------------------------------------------------------------- */
.auth-box .form-actions,
.auth-mobile-box .form-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    margin: 18px 0 0;
    padding: 0;
    border: none;
    text-align: center;
}

.auth-box .form-actions button,
.auth-mobile-box .form-actions button {
    width: 100%;
    margin: 0;
    padding: 11px 16px;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: var(--radius-btn);
}

.auth-box form + form .form-actions,
.auth-mobile-box form + form .form-actions {
    margin-top: 10px;
}

.auth-box .form-actions .back-link,
.auth-mobile-box .form-actions .back-link {
    margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Secondary links
   -------------------------------------------------------------------------- */
.auth-links a,
.auth-mobile-links a,
.forgot-password-link,
.signup-link,
.back-link,
.link-button {
    color: var(--accent-text) !important;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.auth-links a:hover,
.auth-mobile-links a:hover,
.forgot-password-link:hover,
.signup-link:hover,
.back-link:hover,
.link-button:hover {
    color: var(--accent-hover) !important;
    text-decoration: underline;
}

.auth-box .forgot-password-link,
.auth-mobile-box .forgot-password-link {
    font-size: 12.5px;
    margin-top: 6px;
}

.auth-mobile-form .auth-mobile-links,
.auth-mobile-links {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Passkey login — bordered secondary button with accent icon
   -------------------------------------------------------------------------- */
.passkey-primary {
    gap: 10px;
    margin-bottom: 4px;
}

.passkey-btn--primary {
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-btn);
    padding: 11px 16px;
    font-size: 14.5px;
    font-weight: 600;
    box-shadow: var(--shadow-card);
}

.passkey-btn--primary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--ink);
}

.passkey-btn--primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.passkey-btn--primary i {
    color: var(--accent-text);
    font-size: 16px;
}

.link-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    margin: 2px auto 0;
}

/* --------------------------------------------------------------------------
   Alerts / field errors — token tints
   -------------------------------------------------------------------------- */
.alert {
    display: block;
    margin: 16px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    color: var(--ink-secondary);
}

.alert-error,
.alert-danger {
    background: var(--negative-bg);
    border-color: var(--negative-border);
    color: var(--negative);
}

.alert-success {
    background: var(--positive-bg);
    border-color: color-mix(in oklab, var(--positive) 30%, transparent);
    color: var(--positive);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: color-mix(in oklab, var(--warning) 35%, transparent);
    color: var(--warning);
}

.alert-info {
    background: var(--accent-soft);
    border-color: color-mix(in oklab, var(--accent) 25%, transparent);
    color: var(--accent-text);
}

.error-message {
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--negative);
    text-align: left;
}

/* --------------------------------------------------------------------------
   Welcome panel (desktop marketing variant of /auth/login)
   -------------------------------------------------------------------------- */
.auth-mobile-welcome .auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 10px;
}

.auth-mobile-welcome h1 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.auth-mobile-welcome .tagline {
    font-size: 13.5px;
    color: var(--ink-secondary);
    margin: 0 0 22px;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 4px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}

.feature-item i {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-size: 15px;
    color: var(--accent-text);
    background: var(--accent-soft);
    border-radius: 10px;
}

.feature-text h3 {
    margin: 0 0 2px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.feature-text p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--ink-secondary);
}

.auth-links.horizontal {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.auth-links.horizontal .auth-link {
    flex: 1;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-btn);
    text-align: center;
}

.auth-link:hover {
    transform: none;
    box-shadow: none;
}

.auth-link:first-of-type {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--ink-on-accent) !important;
}

.auth-link:first-of-type:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--ink-on-accent) !important;
}

.auth-link:last-of-type {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    color: var(--ink) !important;
}

.auth-link:last-of-type:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--ink) !important;
}

/* --------------------------------------------------------------------------
   2FA setup — numbered steps, white QR card, mono secret
   -------------------------------------------------------------------------- */
.setup-2fa-content {
    font-size: 13.5px;
}

.setup-steps {
    list-style: none;
    counter-reset: setup-step;
    margin: 0 0 18px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setup-steps li {
    counter-increment: setup-step;
    position: relative;
    margin: 0;
    padding-left: 34px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-secondary);
}

.setup-steps li::before {
    content: counter(setup-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 700;
}

/* Deliberately white in BOTH themes so the QR stays scannable. */
.qr-code-container {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: none;
    margin: 0 0 16px;
    padding: 16px;
    text-align: center;
}

.qr-code-container img {
    display: inline-block;
    max-width: 190px;
    height: auto;
}

.manual-entry {
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 12px 14px;
    margin: 0 0 18px;
}

.manual-entry p {
    margin: 0 0 8px;
    font-size: 12.5px;
    color: var(--ink-secondary);
}

.secret-key {
    display: block;
    margin: 0;
    padding: 9px 10px;
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.08em;
    text-align: center;
    word-break: break-all;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--ink);
    user-select: all;
}

.verify-2fa-form {
    max-width: none;
    margin: 0;
}

/* 6-digit code inputs read in mono */
input#code,
input#disable_2fa_code {
    font-family: var(--font-mono);
    text-align: center;
    letter-spacing: 0.3em;
    font-size: 17px;
}

input#code::placeholder,
input#disable_2fa_code::placeholder {
    letter-spacing: normal;
    font-family: var(--font-ui);
    font-size: 13.5px;
}

/* --------------------------------------------------------------------------
   Account page — section cards
   -------------------------------------------------------------------------- */
.account-container {
    padding: 26px 24px 40px;
    max-width: 1160px;
}

.account-container h1 {
    margin: 0 0 18px;
    padding-bottom: 0;
    border-bottom: none;
    text-align: left;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 0;
    padding-bottom: 16px;
}

.account-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 18px 20px 20px;
    height: fit-content;
}

.account-card h2 {
    margin: 0 0 14px;
    padding-bottom: 0;
    border-bottom: none;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-tertiary);
}

.account-card p {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--ink-secondary);
}

.account-form label {
    display: block;
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-secondary);
}

.account-card input:not([type="checkbox"]):not([type="radio"]),
.account-card select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    font-size: 14px;
    background: var(--bg-surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-input);
}

.account-card .form-actions {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    margin: 4px 0 0;
    padding: 0;
    border: none;
    text-align: right;
}

.account-card .form-actions .btn-primary,
.account-card .form-actions .btn-danger {
    width: auto;
    margin: 0;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-btn);
}

/* 2FA status banner */
.status-box {
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.status-box.success {
    background: var(--positive-bg);
    color: var(--positive);
    border: 1px solid color-mix(in oklab, var(--positive) 30%, transparent);
}

/* Pending e-mail change notice */
.pending-email-notice {
    margin-top: 8px;
    padding: 9px 12px;
    background: var(--warning-bg);
    border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
    border-radius: 10px;
    color: var(--warning);
    font-size: 12.5px;
    line-height: 1.5;
}

/* Passkey list rows */
.passkey-list {
    gap: 8px;
    margin: 2px 0 14px;
}

.passkey-row {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.passkey-row-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.passkey-row-meta {
    margin-top: 3px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--ink-tertiary);
}

.passkey-row-actions {
    flex: none;
    gap: 4px;
}

.passkey-row-actions .btn-link {
    background: none;
    border: none;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent-text);
    cursor: pointer;
}

.passkey-row-actions .btn-link:hover {
    background: var(--bg-hover);
    color: var(--accent-text);
    text-decoration: none;
}

.passkey-row-actions .btn-link.btn-danger {
    background: none;
    color: var(--negative);
    width: auto;
    padding: 5px 8px;
}

.passkey-row-actions .btn-link.btn-danger:hover:not(:disabled) {
    background: var(--negative-bg);
    color: var(--negative);
}

.muted {
    color: var(--ink-tertiary);
    font-size: 12.5px;
}

/* Danger zone */
.account-card.danger-zone {
    background: var(--negative-bg);
    border: 1px solid var(--negative-border);
}

.danger-zone h2 {
    color: var(--negative);
    border-bottom: none;
}

.warning-text {
    color: var(--negative);
    font-size: 13px;
    line-height: 1.5;
}

.danger-zone input:not([type="checkbox"]):not([type="radio"]) {
    background: var(--bg-surface);
}

/* --------------------------------------------------------------------------
   Account page — mobile shell adjustments (full-width cards, 14px gutters)
   -------------------------------------------------------------------------- */
.mobile-main .account-container {
    padding: 14px 14px 32px;
}

.mobile-main .account-container h1 {
    text-align: left;
    font-size: 19px;
    margin-bottom: 14px;
}

.mobile-main .account-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0;
}

.mobile-main .account-card {
    padding: 16px 14px;
}

.mobile-main .account-card .form-actions .btn-primary,
.mobile-main .account-card .form-actions .btn-danger {
    width: 100%;
    padding: 11px 16px;
    font-size: 14.5px;
}

.mobile-main .account-card input:not([type="checkbox"]):not([type="radio"]),
.mobile-main .account-card select {
    font-size: 16px; /* prevent iOS zoom */
}
