:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg-body: #f5f6f7;
  --bg-card: #fff;
  --bg-input: #f5f6f7;
  --border: #e0e0e0;
  --text: #1f2026;
  --muted: #8e94a3;
  --accent: #2b5d9f;
  --accent-hover: #1e4578;
  --accent-soft: rgb(43 93 159 / 10%);
  --hover: #f2f2f2;
  --shadow: 0 4px 24px rgb(0 0 0 / 6%);
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error: #dc2626;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info: #1d4ed8;
  --orb-opacity: .3;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-body: #1a1b1e;
  --bg-card: #242529;
  --bg-input: #2d2e32;
  --border: #3a3b40;
  --text: #e8e9eb;
  --muted: #9aa0a6;
  --accent: #4a8fe8;
  --accent-hover: #5ea0f5;
  --accent-soft: rgb(74 143 232 / 16%);
  --hover: #2d2e32;
  --shadow: 0 4px 24px rgb(0 0 0 / 30%);
  --error-bg: #2d1f1f;
  --error-border: #4a2f2f;
  --error: #f87171;
  --info-bg: #1e2a3b;
  --info-border: #334f73;
  --info: #93c5fd;
  --orb-opacity: .15;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg-body);
  color: var(--text);
  transition: background .3s ease, color .3s ease;
}

body::before {
  position: fixed;
  z-index: 0;
  inset: -50%;
  content: "";
  background: radial-gradient(ellipse at 20% 50%, rgb(43 93 159 / 10%), transparent 50%), radial-gradient(ellipse at 80% 20%, rgb(74 143 232 / 8%), transparent 50%), radial-gradient(ellipse at 50% 80%, rgb(6 182 212 / 6%), transparent 50%);
  animation: background-shift 20s ease-in-out infinite alternate;
}

.orb {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  opacity: var(--orb-opacity);
  animation: orb-float 15s ease-in-out infinite;
}

.orb-one { top: -100px; right: -100px; width: 400px; height: 400px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.orb-two { bottom: -80px; left: -80px; width: 300px; height: 300px; background: linear-gradient(135deg, #06b6d4, #3b82f6); animation-delay: -5s; }
.orb-three { top: 50%; left: 60%; width: 200px; height: 200px; background: linear-gradient(135deg, #8b5cf6, #ec4899); animation-delay: -10s; }

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(100%, 420px);
  padding: 48px 40px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  animation: panel-appear .5s cubic-bezier(.16, 1, .3, 1) both;
}

.panel.accounts-panel { width: min(100%, 620px); }

.brand { display: grid; justify-items: center; text-align: center; }
.brand-icon { display: grid; width: 56px; height: 56px; margin-bottom: 20px; place-items: center; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #6366f1); box-shadow: 0 8px 24px rgb(43 93 159 / 30%); animation: icon-float 3s ease-in-out infinite; }
.brand-icon svg { width: 28px; fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

h1 { margin: 0 0 6px; color: var(--text); font-size: 22px; line-height: 1.25; letter-spacing: -.02em; text-align: center; }
.muted { margin: 0 0 36px; color: var(--muted); line-height: 1.5; text-align: center; }
.account-identifier { display: grid; gap: 4px; margin: 0 0 20px; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent); }
.account-identifier span, .session span { color: var(--muted); font-size: 14px; }
.account-identifier strong, .session strong { overflow-wrap: anywhere; font-weight: 600; }

.form { display: grid; gap: 12px; }
.login-panel .brand { margin-bottom: 0; }
.login-panel > h1, .login-panel > .muted { text-align: center; }
.login-panel > .muted { margin-bottom: 36px; }
.login-panel .form { display: block; }
.login-panel .form-group { margin-bottom: 20px; }
.login-panel .form-group label { display: block; margin: 0 0 8px; }
.login-panel .field-error:empty { display: none; }
.input-with-icon { position: relative; }
.input-with-icon > svg, .password-leading-icon { position: absolute; top: 50%; left: 13px; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; pointer-events: none; }
.input-with-icon input, .password-field-with-icon input { padding-left: 42px; }
.options-row { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 28px; }
.login-reset { font-size: 13px; }
.login-submit { width: 100%; min-height: 48px; padding: 13px 24px; }
.login-submit span { display: flex; align-items: center; justify-content: center; gap: 8px; }
.login-submit svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
label { margin-top: 4px; color: var(--text); font-size: 13px; font-weight: 500; }
input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 2px solid transparent;
  border-radius: 10px;
  outline: none;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
input:hover { border-color: var(--border); }
input:focus { border-color: var(--accent); background: var(--bg-card); box-shadow: 0 0 0 4px var(--accent-soft); }

.password-field { position: relative; }
.password-field input { padding-right: 50px; }
.password-toggle { position: absolute; top: 50%; right: 10px; display: grid; width: 30px; height: 30px; padding: 0; place-items: center; transform: translateY(-50%); border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.password-toggle:hover { color: var(--text); background: var(--hover); }
.password-toggle:focus-visible, .theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.password-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.password-toggle-hide, .password-toggle[aria-pressed="true"] .password-toggle-show { display: none; }
.password-toggle[aria-pressed="true"] .password-toggle-hide { display: block; }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 0 16px; border: 0; border-radius: 10px; background: var(--accent); box-shadow: 0 4px 16px rgb(43 93 159 / 30%); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.button:hover { transform: translateY(-1px); background: var(--accent-hover); box-shadow: 0 8px 24px rgb(43 93 159 / 40%); }
.button:active { transform: none; }
.button.secondary { background: var(--hover); box-shadow: none; color: var(--accent); }
.button.secondary:hover { background: var(--accent-soft); }
.link, .link-button { color: var(--accent); font: inherit; font-weight: 500; text-decoration: none; }
.link:hover, .link-button:hover { color: var(--accent-hover); }
.link-button { display: inline; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; pointer-events: none; }

.alert { margin: 0 0 16px; padding: 11px 13px; border: 1px solid var(--error-border); border-radius: 10px; background: var(--error-bg); color: var(--error); font-size: 14px; }
.alert.info { border-color: var(--info-border); background: var(--info-bg); color: var(--info); }
.field-error { color: var(--error); font-size: 13px; }

.sessions, .actions.vertical, .choices { display: grid; gap: 12px; }
.session { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-input); }
.session-info { min-width: 0; }
.session strong { display: block; line-height: 1.35; }
.session span { display: block; margin-top: 4px; }
.session-actions, .actions { display: flex; gap: 12px; align-items: center; }
.actions.centered { justify-content: center; }
.session-actions form { margin: 0; }
.accounts-add { display: inline-block; margin-top: 16px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 9px; background: var(--hover); color: var(--muted); font-size: 22px; cursor: pointer; }
.icon-button:hover { color: var(--error); }
.form.compact, .webauthn-form { margin-top: 16px; }
.code-block, .webauthn-status, .scope-list { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); color: var(--text); }
.code-block { margin-bottom: 12px; overflow-wrap: anywhere; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.code-block.small { font-size: 12px; }
.scope-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.scope-list span { padding: 4px 8px; border-radius: 999px; background: var(--accent-soft); font-size: 13px; }

.theme-toggle { position: fixed; z-index: 2; top: 24px; right: 24px; display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card); color: var(--muted); cursor: pointer; transition: color .2s ease, border-color .2s ease, transform .2s ease; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.05); }
.theme-toggle svg { width: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.theme-icon-moon, :root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }

@keyframes panel-appear { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes background-shift { to { transform: translate(-5%, -5%) rotate(3deg); } }
@keyframes orb-float { 50% { transform: translateY(-30px) scale(1.05); } }
@keyframes icon-float { 50% { transform: translateY(-6px); } }

@media (max-width: 520px) {
  .shell { padding: 16px; }
  .panel { padding: 36px 24px; }
  .theme-toggle { top: 16px; right: 16px; }
  .session { grid-template-columns: 1fr; gap: 14px; }
  .session-actions { width: 100%; }
  .session-actions form:first-child, .session-actions .button { flex: 1; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
