/* ============================================================================
   Sufficit Identity UI — site.css
   Brand-aligned design system. Sufficit red (#cc0000) on calm white/gray.
   Professional, secure, direct. See docs/design/DESIGN-SYSTEM.md.
   ========================================================================== */

/* --- Font face (self-hosted Inter) ---------------------------------------- */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/inter-latin.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/inter-latin-500.woff2") format("woff2");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/inter-latin-600.woff2") format("woff2");
}

/* --- Tokens --------------------------------------------------------------- */
:root {
    /* Brand (exact, from Papelaria/Logo.png) */
    --brand:            #cc0000;
    --brand-hover:      #a30000;
    --brand-press:      #7a0000;
    --brand-soft:       #fbe9e9;
    --brand-ring:       rgba(204, 0, 0, 0.25);

    /* Ink (charcoal family from the logo) */
    --ink:              #343132;
    --ink-strong:       #1f1d1e;
    --ink-muted:        #58595b;
    --ink-subtle:       #8a8b8d;

    /* Surfaces */
    --surface:          #ffffff;
    --surface-page:     #f4f4f5;
    --surface-sunken:   #efeeef;
    --surface-overlay:  rgba(34, 32, 33, 0.55);

    /* Lines */
    --line:             #e2e1e3;
    --line-strong:      #cfced1;

    /* Status (paired with icon + text, never color alone) */
    --danger:           #b42318;
    --danger-soft:      #fef3f2;
    --success:          #157f3f;
    --success-soft:     #effaf2;
    --warning:          #b54708;
    --warning-soft:     #fff8eb;
    --info:             #175cd3;
    --info-soft:        #eff4ff;

    /* Radii */
    --radius-sm:        6px;
    --radius:           8px;
    --radius-lg:        14px;
    --radius-pill:      9999px;

    /* Shadow — card has real presence */
    --shadow-card:      0 4px 24px rgba(34,32,33,.06), 0 1px 4px rgba(34,32,33,.04);
    --shadow-pop:       0 8px 32px rgba(34,32,33,.10), 0 2px 8px rgba(34,32,33,.06);
    --shadow-btn:       0 1px 2px rgba(204,0,0,.25);
    --shadow-btn-hover: 0 2px 6px rgba(204,0,0,.30);

    /* Motion */
    --ease:             cubic-bezier(.2,.0,.0,1);
    --dur-fast:         120ms;
    --dur:              180ms;

    /* Typography */
    --font-sans:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                        "Helvetica Neue", Arial, sans-serif;
    --font-mono:        "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code",
                        "Courier New", monospace;

    /* Spacing scale (4px base) */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-14: 56px;
    --space-20: 80px;
}

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

/* Keep the HTML hidden state authoritative even when a component class sets
   an explicit display value (for example .btn uses inline-flex). */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    color: var(--ink);
    background-color: var(--surface-page);
    line-height: 1.5;
    font-size: 16px;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page background: Sufficit brand background image with overlay (from legacy STS) */
body {
    background:
        linear-gradient(rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)),
        url("../img/login-bg.jpg") center / cover fixed no-repeat;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink-strong); }

a {
    color: var(--brand);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--brand-hover); text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* --- Layout --------------------------------------------------------------- */
.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-10) var(--space-4);
}

/* --- Topbar --------------------------------------------------------------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0 var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.topbar-brand a {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--ink);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.topbar-brand a:hover { color: var(--ink); }
.topbar-brand .brand-mark {
    width: 32px;
    height: 32px;
    display: block;
    flex-shrink: 0;
}
.topbar-brand .brand-wordmark {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.1;
}
.topbar-brand .brand-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
}
.topbar-brand .brand-sub {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--ink-subtle);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.topbar-nav { display: flex; gap: var(--space-2); align-items: center; }
.culture-selector {
    display: inline-flex;
    align-items: center;
    --sui-color-primary: var(--brand);
    --sui-color-primary-soft: var(--brand-ring);
    --sui-surface: var(--surface);
    --sui-surface-2: var(--surface-sunken);
    --sui-text-primary: var(--ink);
    --sui-text-secondary: var(--ink-muted);
    --sui-border: var(--line);
    --sui-border-strong: var(--line-strong);
}
.culture-selector .sui-field {
    width: auto;
    gap: 0;
}
.culture-selector .sui-field__label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.culture-selector .sui-select__trigger,
.culture-selector__fallback select {
    min-width: 104px;
    min-height: 44px;
    height: 44px;
    padding-inline: 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink-muted);
    font: 600 0.78rem/1 var(--font-sans);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease),
                background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.culture-selector .sui-select__trigger:hover,
.culture-selector__fallback select:hover {
    border-color: var(--ink-subtle);
    background: var(--surface-sunken);
    color: var(--ink);
}
.culture-selector .sui-select__trigger:focus-visible,
.culture-selector__fallback select:focus-visible {
    border-color: var(--brand);
    outline: 2px solid var(--brand-ring);
    outline-offset: 2px;
}
.culture-selector .sui-select__menu {
    padding: 6px;
    border-color: var(--line-strong);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    box-shadow: 0 14px 36px rgba(28, 23, 25, 0.16);
    backdrop-filter: blur(12px);
}
.culture-selector .sui-select__option {
    min-height: 40px;
    border-radius: calc(var(--radius-lg) - 4px);
    font: 600 0.82rem/1.2 var(--font-sans);
}
.culture-selector__fallback {
    display: inline-flex;
    align-items: center;
}
.culture-selector__submit {
    min-height: 44px;
    margin-left: var(--space-2);
    padding: 0 var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font: 600 0.75rem/1 var(--font-sans);
}
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.nav-link {
    color: var(--ink-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.nav-link:hover {
    color: var(--ink);
    background: var(--surface-sunken);
    text-decoration: none;
}

/* --- Footer --------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: var(--space-5) var(--space-8);
    color: var(--ink-muted);
    font-size: 0.85rem;
    font-weight: 500;
    border-top: 1px solid var(--line);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.footer a {
    color: var(--brand);
    font-weight: 500;
}
.footer a:hover { color: var(--brand-hover); }
.footer-links { white-space: nowrap; }
.footer-server {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--ink-muted);
}
.footer-server code {
    overflow-wrap: anywhere;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
}
.footer-server__status {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--success);
}

@media (max-width: 640px) {
    .footer { justify-content: center; text-align: center; }
    .footer-server { width: 100%; order: -1; }
}

/* --- Brand header (above auth card on login/register) --------------------- */
.auth-brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-6);
}
.auth-brand img {
    height: 44px;
    width: auto;
}

/* --- Auth card (centered) — glassmorphism over brand background ----------- */
.auth-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(34, 32, 33, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: var(--space-10);
    width: 100%;
    max-width: 440px;
}
.auth-card h1 {
    margin: 0 0 var(--space-2);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ink-strong);
    letter-spacing: -0.02em;
}
.auth-card h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--ink-strong);
}
.auth-card h3 {
    margin: var(--space-8) 0 var(--space-3);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink);
}
.auth-card-subtitle {
    margin: 0 0 var(--space-6);
    font-size: 0.9375rem;
    color: var(--ink-muted);
    line-height: 1.5;
}
.auth-card-center {
    text-align: center;
}
.auth-card-center .auth-brand { margin-bottom: var(--space-5); }
.auth-card-center .btn-group { justify-content: center; }
.auth-divider {
    margin: var(--space-6) 0;
    border: none;
    border-top: 1px solid var(--line);
}
.auth-links {
    margin-top: var(--space-6);
    text-align: center;
    font-size: 0.875rem;
    color: var(--ink-muted);
    line-height: 2.2;
}
.auth-links a { color: var(--brand); font-weight: 500; }

/* --- Forms ---------------------------------------------------------------- */
.form-group { margin-bottom: var(--space-5); }
.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--ink);
    letter-spacing: 0.01em;
}
.form-control {
    width: 100%;
    height: 48px;
    padding: 0 var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-family: var(--font-sans);
    color: var(--ink);
    background-color: var(--surface);
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.form-control::placeholder { color: var(--ink-subtle); }
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.form-control[disabled], .form-control[readonly] {
    background-color: var(--surface-sunken);
    color: var(--ink-muted);
    cursor: not-allowed;
}
.field-hint {
    display: block;
    margin-top: var(--space-2);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.human-verification {
    margin: 0 0 var(--space-5);
    min-width: 0;
}
.human-verification__label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--ink);
    font-size: 0.8125rem;
    font-weight: 500;
}
.human-verification__widget {
    min-height: 65px;
    max-width: 100%;
    overflow: hidden;
}
.human-verification__widget[data-load-failed="true"] {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--danger);
    border-radius: var(--radius);
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 0.8125rem;
}
.human-verification__hint {
    margin: var(--space-2) 0 0;
    color: var(--ink-muted);
    font-size: 0.75rem;
}
.form-control-static {
    display: block;
    padding: var(--space-3) 0;
    font-size: 0.9375rem;
    color: var(--ink);
}
.form-check {
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.form-check label {
    margin: 0;
    font-weight: 400;
    color: var(--ink);
    font-size: 0.9375rem;
}
.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
    margin: 0;
}

/* Device code input (larger, monospace) */
.device-code {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    letter-spacing: 0.25em;
    text-align: center;
    text-transform: uppercase;
    height: 64px;
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 48px;
    padding: 0 var(--space-6);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--ink);
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: background var(--dur) var(--ease),
                border-color var(--dur) var(--ease),
                color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease),
                transform var(--dur-fast) var(--ease);
}
.btn:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}
.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
    background: var(--brand-hover);
    border-color: var(--brand-hover);
    color: #fff;
    box-shadow: var(--shadow-btn-hover);
    text-decoration: none;
}
.btn-primary:active {
    background: var(--brand-press);
    transform: translateY(1px);
}
.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn-secondary:hover {
    background: var(--surface-sunken);
    border-color: var(--line-strong);
    text-decoration: none;
}
.btn-secondary:active { transform: translateY(1px); }
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #8e1a13;
    border-color: #8e1a13;
    color: #fff;
    text-decoration: none;
}
.btn-external {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    width: 100%;
    margin-bottom: var(--space-2);
    min-height: 48px;
}
.btn-external:hover {
    background: var(--surface-sunken);
    border-color: var(--line-strong);
    text-decoration: none;
}

/* Social login buttons */
.btn-google,
.btn-facebook,
.btn-passkey {
    margin-bottom: var(--space-3);
}
.btn-google {
    background: var(--surface);
    color: #1f2937;
    border: 1px solid #d7dce2;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10);
    font-weight: 600;
}
.btn-google:hover {
    background: #f8fafc;
    border-color: #b8c0cc;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
    color: #1f2937;
    text-decoration: none;
}
.btn-facebook {
    background: #1877F2;
    color: #fff;
    border: 1px solid #1877F2;
    font-weight: 600;
}
.btn-facebook:hover {
    background: #166fe5;
    border-color: #166fe5;
    box-shadow: 0 4px 14px rgba(24, 119, 242, 0.30);
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}
.provider-icon {
    flex-shrink: 0;
}
.btn-passkey {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line-strong);
    width: 100%;
    font-weight: 600;
    min-height: 48px;
}
.btn-passkey:hover {
    background: var(--surface-sunken);
    border-color: var(--brand);
    color: var(--ink);
    text-decoration: none;
}
.btn-block { width: 100%; }
.btn-sm {
    min-height: 34px;
    padding: 0 var(--space-4);
    font-size: 0.8125rem;
}
.btn-group {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}
.btn[disabled], .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Alerts --------------------------------------------------------------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    margin-bottom: var(--space-5);
    font-size: 0.875rem;
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    line-height: 1.5;
    font-weight: 500;
}
.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-left: 3px solid var(--danger);
}
.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-left: 3px solid var(--success);
}
.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-left: 3px solid var(--warning);
}
.alert-info {
    background: var(--info-soft);
    color: var(--info);
    border-left: 3px solid var(--info);
}
.registration-success {
    display: block;
    padding: var(--space-4);
    border-left-width: 1px;
}
.registration-success__content,
.registration-success__content p {
    min-width: 0;
}
.registration-success__content p {
    margin: 0;
}
.registration-success__content p + p {
    margin-top: var(--space-2);
}
.registration-success__title {
    color: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
}
.registration-success__email {
    overflow-wrap: anywhere;
}

/* --- Badges --------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    background: var(--surface-sunken);
    color: var(--ink-muted);
    line-height: 1.6;
    letter-spacing: 0.02em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-outline {
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--ink-muted);
}

/* --- Utility -------------------------------------------------------------- */
.info {
    color: var(--ink);
    margin-bottom: var(--space-4);
    line-height: 1.5;
    font-size: 0.9375rem;
}
.muted { color: var(--ink-muted); font-size: 0.875rem; }
.muted code { color: var(--ink); }

/* --- Consent scope list --------------------------------------------------- */
.consent-card {
    max-width: 800px;
}
.scope-list {
    border: none;
    padding: 0;
    margin: 0 0 var(--space-6);
}
.scope-list legend {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--ink);
    margin-bottom: var(--space-3);
    padding: 0;
}
.scope-item {
    display: grid;
    grid-template-columns: 18px minmax(13.5rem, 0.65fr) minmax(0, 1.35fr);
    align-items: flex-start;
    column-gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.scope-item:hover {
    background: var(--surface-sunken);
    border-color: var(--line-strong);
}
.scope-item input[type="checkbox"] {
    margin-top: 0.15rem;
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
    cursor: pointer;
    flex-shrink: 0;
}
.scope-name {
    min-width: 0;
    color: var(--ink);
    font-weight: 500;
    line-height: 1.45;
}
.scope-desc {
    min-width: 0;
    font-size: 0.8125rem;
    color: var(--ink-muted);
    line-height: 1.45;
}
.consent-submitted {
    margin: var(--space-5) 0 0;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-sunken);
}
.consent-submitted strong { display: block; margin-bottom: var(--space-1); }
.consent-submitted p { margin: 0; }

@media (max-width: 768px) {
    .scope-item {
        grid-template-columns: 18px minmax(0, 1fr);
        row-gap: var(--space-1);
    }
    .scope-item input[type="checkbox"] {
        grid-row: 1 / span 2;
    }
    .scope-name,
    .scope-desc {
        grid-column: 2;
    }
}

/* --- External login separator -------------------------------------------- */
.separator {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-6) 0 var(--space-3);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}
.separator::before,
.separator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}
.separator span {
    padding: 0;
    white-space: nowrap;
}

.external-logins, .external-providers { margin-top: var(--space-3); }

/* --- Manage area ---------------------------------------------------------- */
.manage-grid { max-width: 640px; }

.manage-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--ink-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: var(--space-5);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    transition: background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.manage-back:hover {
    color: var(--brand);
    background: var(--surface-sunken);
    text-decoration: none;
}
.manage-back svg { flex-shrink: 0; }

.profile-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: var(--space-5) 0 var(--space-8);
    padding: var(--space-5);
    background: var(--surface-sunken);
    border-radius: var(--radius-lg);
}
.profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    flex-shrink: 0;
    object-fit: cover;
}
img.profile-avatar { background: var(--surface-sunken); }

.manage-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}
.manage-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease);
}
.manage-link:hover {
    background: var(--surface-sunken);
    border-color: var(--line-strong);
    text-decoration: none;
}
.manage-link::after {
    content: "→";
    color: var(--ink-subtle);
    font-size: 1rem;
    font-weight: 400;
    transition: transform var(--dur-fast) var(--ease);
}
.manage-link:hover::after { transform: translateX(3px); }

/* Passkeys list */
.passkey-list, .external-list, .grant-list, .session-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-6);
}
.passkey-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
}
.passkey-item-info {
    flex: 1;
    min-width: 0;
}
.passkey-name {
    display: block;
    color: var(--ink);
    font-weight: 600;
    overflow-wrap: anywhere;
}
.passkey-meta {
    display: block;
    margin: var(--space-1) 0 var(--space-2);
    color: var(--ink-muted);
    font-size: 0.8125rem;
}
.passkey-item-actions,
.passkey-inline-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}
.passkey-inline-editor {
    width: 100%;
    margin: 0;
}
.passkey-inline-editor .form-control {
    height: 42px;
}
.passkey-inline-actions {
    margin-top: var(--space-3);
}
.passkey-form { width: 100%; }
.passkey-list li, .external-list li {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}
.external-item-info { flex: 1; min-width: 0; }
.external-item-name { font-weight: 600; color: var(--ink); font-size: 0.9375rem; }
.external-item-reason {
    display: block;
    margin-top: var(--space-1);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
}
.external-section + .external-section {
    margin-top: var(--space-7);
}

/* Grants */
.manage-grants {
    max-width: 760px;
}

.manage-grants__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
}

.manage-grants__header .info {
    max-width: 48ch;
    margin-bottom: 0;
}

.manage-grants__header .badge {
    flex: 0 0 auto;
    margin-top: 2px;
}

.grant-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--space-2);
}

/* Sessions */
.manage-sessions {
    max-width: 760px;
}

.manage-sessions__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-5);
}

.manage-sessions__header .info {
    max-width: 48ch;
    margin-bottom: 0;
}

.manage-sessions__header .badge {
    flex: 0 0 auto;
    margin-top: 2px;
}

.session-groups {
    list-style: none;
    padding: 0;
    margin: var(--space-6) 0;
}

.session-group {
    padding: var(--space-5) 0;
    border-top: 1px solid var(--line);
}

.session-group:first-child {
    padding-top: 0;
    border-top: 0;
}

.session-group__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.session-group__title {
    display: block;
    color: var(--ink-strong);
    font-size: 0.9375rem;
}

.session-credential-list {
    list-style: none;
    padding: 0;
    margin: var(--space-3) 0 0;
}

.session-credential {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--space-4);
    padding: var(--space-3) 0 0;
    margin-top: var(--space-3);
    border-top: 1px solid var(--line);
}

.session-credential .access-metadata {
    margin-top: 0;
}
.access-item-body {
    flex: 1;
    min-width: 0;
}
.access-item-title {
    display: block;
    color: var(--ink-strong);
    font-size: 0.9375rem;
}
.access-client-id {
    display: block;
    margin-top: var(--space-1);
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}
.access-metadata {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0 0;
}
.access-metadata div {
    display: grid;
    grid-template-columns: minmax(8rem, auto) minmax(0, 1fr);
    align-items: start;
    gap: var(--space-2);
}
.access-metadata dt,
.access-metadata dd {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
}
.access-metadata dt {
    color: var(--ink-muted);
    font-weight: 600;
}
.access-metadata dd {
    min-width: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.scope-list-inline {
    display: flex;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
}

.scope-chip {
    max-width: 100%;
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

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

.access-item-action {
    min-height: 44px;
    flex-shrink: 0;
}
.session-revoke-all {
    padding-top: var(--space-5);
    border-top: 1px solid var(--line);
}
.session-revoke-all .muted {
    margin-bottom: var(--space-3);
}

/* --- 2FA / Recovery codes ------------------------------------------------- */
.qr-container {
    text-align: center;
    margin: var(--space-5) 0;
}
.qr-container img {
    max-width: 200px;
    border-radius: var(--radius);
}
.manual-key {
    display: block;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--surface-sunken);
    padding: var(--space-3);
    border-radius: var(--radius);
    margin: var(--space-3) 0 var(--space-5);
    word-break: break-all;
    color: var(--ink);
}
.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2) var(--space-4);
    margin: var(--space-5) 0;
    padding: var(--space-5);
    background: var(--surface-sunken);
    border-radius: var(--radius);
}
.recovery-code {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.9375rem;
    padding: var(--space-1) 0;
    color: var(--ink-strong);
    letter-spacing: 0.05em;
    overflow-wrap: anywhere;
    text-align: center;
}
.two-factor-actions {
    align-items: stretch;
    flex-direction: column;
}

/* --- Device flow ---------------------------------------------------------- */
.device-authorization-card { max-width: 560px; }
.device-authorization-header { margin-bottom: var(--space-6); }
.device-authorization-header p {
    margin: 0;
    color: var(--ink-muted);
    font-size: 0.9375rem;
    line-height: 1.55;
}
.device-authorization-header strong { color: var(--ink); }
.device-client {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-sunken);
    border-radius: var(--radius);
}
.device-client__mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: var(--radius);
    background: var(--ink-strong);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
}
.device-client__identity {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 1px;
}
.device-client__identity strong {
    overflow: hidden;
    color: var(--ink-strong);
    font-size: 0.9375rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.device-client__identity code {
    overflow: hidden;
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.device-code-confirmation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.8125rem;
}
.device-code-confirmation strong {
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.04em;
}
.device-permissions { margin-top: var(--space-6); }
.device-permissions h2 {
    margin: 0 0 var(--space-3);
    font-size: 0.9375rem;
}
.device-scope-list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}
.device-scope-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}
.device-scope-item__check {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 600;
}
.device-scope-item strong {
    display: block;
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
}
.device-scope-item small {
    display: block;
    margin-top: 1px;
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
}
.device-scope-item__identifier {
    display: inline-block;
    max-width: 100%;
    margin-top: var(--space-1);
    padding: 2px 6px;
    overflow-wrap: anywhere;
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
}
.device-permissions__empty {
    margin: 0;
    color: var(--ink-muted);
    font-size: 0.875rem;
}
.device-resources {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.8125rem;
}
.device-resources summary {
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
}
.device-resources p {
    margin: var(--space-2) 0;
    line-height: 1.5;
}
.device-resources ul {
    margin: 0;
    padding-left: var(--space-5);
}
.device-resources code {
    overflow-wrap: anywhere;
    color: var(--ink-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}
.device-validity {
    display: grid;
    gap: var(--space-3);
    margin: var(--space-6) 0 0;
    padding: var(--space-4) 0 0;
    border-top: 1px solid var(--line);
}
.device-validity__row {
    display: grid;
    grid-template-columns: minmax(118px, 0.36fr) minmax(0, 1fr);
    gap: var(--space-4);
}
.device-validity dt {
    color: var(--ink-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}
.device-validity dd {
    display: flex;
    min-width: 0;
    margin: 0;
    flex-direction: column;
    gap: 2px;
}
.device-validity dd strong {
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
}
.device-validity dd span {
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
}
.device-safety-note {
    margin: var(--space-6) 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--warning-soft);
    color: #7a2e0e;
    font-size: 0.8125rem;
    line-height: 1.5;
}
.device-authorization-actions { margin-top: 0; }
.device-result { text-align: center; }
.device-result__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin: 0 auto var(--space-5);
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
    font-size: 1.5rem;
    font-weight: 600;
}
.device-result__icon--denied {
    background: var(--danger-soft);
    color: var(--danger);
}
.device-result p {
    margin: 0 0 var(--space-6);
    color: var(--ink-muted);
    font-size: 0.9375rem;
}
.device-close-fallback {
    margin: var(--space-4) 0 0;
    color: var(--ink-muted);
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: center;
}

@media (max-width: 520px) {
    .device-validity__row {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }
}

/* --- Validation messages -------------------------------------------------- */
.validation-message {
    color: var(--danger);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: var(--space-1);
    display: block;
}
.validation-summary {
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid currentColor;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: var(--space-5);
    padding: var(--space-3) var(--space-4);
}
.validation-summary:empty {
    display: none;
}
.validation-summary ul {
    margin: 0;
    padding-inline-start: var(--space-5);
}

/* --- Access denied -------------------------------------------------------- */
.access-denied {
    text-align: center;
    padding: var(--space-20) var(--space-4);
    color: var(--ink-muted);
}

/* --- Redirect overlay ----------------------------------------------------- */
.redirect-overlay {
    position: fixed;
    inset: 0;
    background: rgba(244, 244, 245, 0.95);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.redirect-overlay-box { text-align: center; color: var(--ink); }
.redirect-overlay-box p {
    margin: var(--space-4) 0 0;
    font-weight: 500;
    font-size: 0.9375rem;
}
.redirect-overlay-box p.redirect-overlay-hint {
    margin-top: var(--space-1);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    font-weight: 400;
}
.spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border: 3px solid var(--line);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 768px) {
    .content {
        align-items: stretch;
        padding: 0;
    }
    .auth-card {
        padding: var(--space-6);
        max-width: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
        /* Keep glass effect on mobile — card still floats over background */
    }
    .human-verification__widget {
        transform-origin: left top;
    }
    .topbar { padding: 0 var(--space-4); height: 56px; }
    .topbar-brand .brand-sub { display: none; }
    .btn-group { flex-direction: column; }
    .device-authorization-card { padding: var(--space-6); }
    .device-client .badge { display: none; }
    .device-code-confirmation { align-items: flex-start; flex-direction: column; gap: var(--space-1); }
    /* Keep manage-nav vertically stacked on mobile (the default column
       layout from line ~724). A previous version forced it into a
       horizontally scrollable row, which made the menu items appear
       side-by-side on phones. */
    .manage-link {
        padding: var(--space-3) var(--space-4);
        font-size: 0.9375rem;
    }
    .grant-item,
    .session-item,
    .passkey-item {
        align-items: stretch;
        flex-direction: column;
    }

    .manage-grants,
    .manage-sessions {
        padding: var(--space-6) max(var(--space-4), env(safe-area-inset-right))
            var(--space-8) max(var(--space-4), env(safe-area-inset-left));
    }

    .manage-grants__header {
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-3);
    }

    .manage-grants__header .badge {
        align-self: flex-start;
        margin-top: 0;
    }

    .manage-sessions__header {
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-3);
    }

    .manage-sessions__header .badge {
        align-self: flex-start;
        margin-top: 0;
    }

    .manage-grants .grant-list {
        margin-top: var(--space-5);
    }

    .grant-item,
    .session-credential {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-4);
        padding: var(--space-4);
    }

    .session-credential {
        padding-right: 0;
        padding-left: 0;
    }

    .passkey-item .btn { align-self: flex-start; }
    .passkey-item-actions,
    .passkey-inline-actions {
        align-self: flex-start;
        flex-wrap: wrap;
    }
    .access-item-action {
        align-self: stretch;
        width: 100%;
    }
    .access-metadata div {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }
    .external-list li {
        align-items: flex-start;
    }
    .recovery-codes {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .content { padding: var(--space-14) var(--space-4); }
}

/* --- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .spinner {
        animation: none;
        border-top-color: var(--brand);
        border-left-color: var(--brand);
    }
}

/* --- High contrast: ensure focus ring stays visible ---------------------- */
@media (forced-colors: active) {
    .btn, .form-control, .scope-item, .manage-link {
        border: 1px solid CanvasText;
    }
    .btn-primary, .btn-danger {
        forced-color-adjust: none;
        color: HighlightText;
    }
}
