/* Theos login theme — matches the portal launcher (frontend/css/portal.css).
   Dark-first, with light/auto/dark via data-theme (auto follows the OS).
   The theme choice is stored in localStorage['theme'], shared same-origin with
   the portal, so a user's selection carries across login → portal. */

:root {
  --bg: #0b0b14;
  --bg-2: #12121f;
  --surface: rgba(255,255,255,0.035);
  --surface-2: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.16);
  --fg: #ececf5;
  --muted: #8a8aa8;
  --accent: #a78bfa;
  --danger: #f87171;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius: 16px;
  --radius-input: 10px;
}
/* explicit light */
:root[data-theme="light"] {
  --bg: #f5f5fa; --bg-2: #ececf3;
  --surface: #ffffff; --surface-2: #f2f2f8;
  --border: rgba(20,20,40,0.10); --border-strong: rgba(20,20,40,0.22);
  --fg: #16162a; --muted: #5c5c78; --accent: #2563eb; --danger: #dc2626;
}
/* auto (or unset) follows the OS */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #f5f5fa; --bg-2: #ececf3;
    --surface: #ffffff; --surface-2: #f2f2f8;
    --border: rgba(20,20,40,0.10); --border-strong: rgba(20,20,40,0.22);
    --fg: #16162a; --muted: #5c5c78; --accent: #2563eb; --danger: #dc2626;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  min-height: 100vh; position: relative; overflow-x: hidden;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ambient brand light — two slowly-drifting layers (transform-only = GPU-cheap) */
body::before, body::after {
  content: ''; position: fixed; z-index: 0; pointer-events: none; inset: -25%; will-change: transform;
}
body::before {
  background: radial-gradient(45vw 42vh at 30% 22%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%);
  animation: driftA 32s ease-in-out infinite;
}
body::after {
  background: radial-gradient(42vw 40vh at 74% 80%, color-mix(in srgb, #38bdf8 16%, transparent), transparent 70%);
  animation: driftB 40s ease-in-out infinite;
}
:root[data-theme="light"] body::before, :root[data-theme="light"] body::after { opacity: 0.5; }
@keyframes driftA { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(5%,4%) scale(1.1); } }
@keyframes driftB { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-4%,-5%) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { body::before, body::after { animation: none; } }

/* ---- theme switch (top-right) ---- */
.theme-switch {
  position: fixed; top: 1rem; right: 1rem; z-index: 3;
  display: inline-flex; gap: 0.15rem; padding: 0.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.theme-switch button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 0.78rem; padding: 0.3rem 0.7rem; border-radius: 999px; line-height: 1;
}
.theme-switch button:hover { color: var(--fg); }
.theme-switch button.is-active {
  color: var(--fg); background: color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ---- auth card ---- */
.auth { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: clamp(1rem, 4vw, 3rem); }
.auth__card {
  width: min(420px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(1.5rem, 4vw, 2.5rem); display: grid; gap: 1.2rem;
  box-shadow: 0 24px 70px rgba(0,0,0,0.45);
  backdrop-filter: blur(12px);
}
:root[data-theme="light"] .auth__card { box-shadow: 0 20px 50px rgba(20,20,40,0.12); }
.auth__brand { display: flex; align-items: center; gap: 0.6rem; color: var(--muted); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.auth__mark { width: 12px; height: 12px; background: var(--accent); transform: rotate(45deg); border-radius: 2px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.auth__org { font-weight: 500; }
.auth__title { font-size: 28px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }
.auth__subtitle { font-size: 14px; color: var(--muted); margin-top: -0.6rem; }
.auth__notice { font-size: 13.5px; padding: 0.75rem 0.875rem; border-radius: var(--radius-input); border: 1px solid var(--border); background: var(--surface-2); }
.auth__notice--error { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.auth__form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.4rem; }
.field__label { font-size: 12px; letter-spacing: 0.05em; color: var(--muted); text-transform: uppercase; }
.field__input {
  width: 100%; padding: 0.75rem 0.875rem; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-input); font-size: 15px; color: var(--fg);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.auth__row { display: flex; align-items: center; }
.auth__row--end { justify-content: flex-end; }
.auth__link { font-size: 13px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.8rem 1rem; border-radius: var(--radius-input); font-size: 14.5px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: transform 140ms ease, box-shadow 200ms ease, background 140ms ease;
}
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 45%, transparent); }
.btn--primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn__glyph { transition: transform 140ms ease; }
.btn:hover .btn__glyph { transform: translateX(2px); }
.auth__foot { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 11.5px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.auth__chip { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 10px #34d399; }

/* TOTP setup */
.auth__qr { display: grid; justify-items: center; gap: 0.5rem; text-align: center; }
.auth__qr-img { width: 180px; height: 180px; border-radius: var(--radius-input); background: #fff; padding: 8px; }
.auth__secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; letter-spacing: 0.06em; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-input); padding: 0.5rem 0.75rem; word-break: break-all; user-select: all; }

@media (prefers-reduced-motion: no-preference) {
  .auth__card { animation: rise 460ms cubic-bezier(.2,.7,.2,1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
}


