:root {
    --bg: #0b0d12;
    --panel: #12151c;
    --panel-2: #171b24;
    --panel-3: #1c212c;
    --border: #232936;
    --border-strong: #2c3343;
    --text: #e6e9ef;
    --text-muted: #9aa3b2;
    --text-dim: #6b7280;
    --accent: #6366f1;
    --accent-2: #818cf8;
    --accent-soft: rgba(99, 102, 241, .15);
    --warn: #f59e0b;
    --danger: #ef4444;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-shell { width: 100%; max-width: 480px; }

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.logo-stack { display: flex; justify-content: center; margin-bottom: 18px; }
.logo {
    display: inline-block;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

p.lede {
    margin: 6px 0 24px;
    color: var(--text-muted);
    text-align: center;
    font-size: 13.5px;
}

button {
    font-family: inherit;
    cursor: pointer;
}

button.oauth {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid #fff;
    background: #fff;
    color: #1f1f1f;
    margin-bottom: 10px;
}

button.oauth.github {
    background: #1f2937;
    color: #fff;
    border-color: #2c3343;
}

button.oauth:hover { filter: brightness(0.97); }

button.oauth .glyph {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

button.oauth .glyph.google {
    background: conic-gradient(from -45deg at 50% 50%, #ea4335 0deg 90deg, #fbbc05 90deg 180deg, #34a853 180deg 270deg, #4285f4 270deg 360deg);
    border-radius: 50%;
    position: relative;
}

button.oauth .glyph.google::after {
    content: '';
    position: absolute;
    inset: 4px;
    background: #fff;
    border-radius: 50%;
}

button.oauth .glyph.github {
    background: #fff;
    -webkit-mask: radial-gradient(circle at 50% 40%, transparent 4px, #000 4.5px) center/100% 100%;
            mask: radial-gradient(circle at 50% 40%, transparent 4px, #000 4.5px) center/100% 100%;
    border-radius: 50%;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 14px;
    color: var(--text-dim);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

button.recovery-link {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 13.5px;
}

button.recovery-link .small {
    display: block;
    color: var(--text-muted);
    font-size: 11.5px;
    margin-top: 2px;
}

button.recovery-link:hover { background: var(--panel-3); }

.recovery-form,
.api-key-form {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

[hidden] { display: none !important; }

label.field { display: block; }

label.field .label-text {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type=email],
input[type=text] {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
}

input[type=email]:focus,
input[type=text]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .2);
}

button.primary {
    width: 100%;
    padding: 11px 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

button.back-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12.5px;
    text-decoration: underline;
    padding: 4px;
}

.api-key-form .api-key-explain {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.more-options {
    margin-top: 16px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
}

.more-options a { color: var(--accent-2); text-decoration: none; }
.more-options a:hover { text-decoration: underline; }

.auth-foot {
    margin-top: 28px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-dim);
}

/* All links inside the auth card use the indigo accent so the support /
   recovery links never fall through to the browser-default visited blue/red,
   which clashes badly on the dark background. */
.auth-card a,
.auth-foot a {
    color: var(--accent-2);
    text-decoration: none;
}
.auth-card a:hover,
.auth-foot a:hover {
    text-decoration: underline;
}

.auth-error {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(239, 68, 68, .35);
    border-radius: 8px;
    background: rgba(239, 68, 68, .12);
    color: #fca5a5;
    font-size: 12.5px;
}

.confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    color: var(--accent-2);
    font-size: 28px;
}

.error-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(245, 158, 11, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    color: var(--warn);
    font-size: 28px;
}

[data-theme="light"] {
    --bg: #f0f7ff;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --panel-3: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --accent-soft: rgba(99, 102, 241, 0.08);
}

html, body { transition: background-color 0.25s ease, color 0.25s ease; }
