:root {
  color-scheme: dark;
  --bg: #090c12;
  --panel: #111620;
  --surface: #171d29;
  --surface-hover: #1d2533;
  --border: #283142;
  --text: #f5f7fb;
  --secondary: #a4adbd;
  --muted: #737f92;
  --primary: #7181ff;
  --ai: #35d0ba;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --font: Inter, Geist, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --surface-hover: #eaf0f7;
  --border: #d9e1ec;
  --text: #17202d;
  --secondary: #5d6879;
  --muted: #8590a2;
  --shadow: 0 24px 70px rgba(35, 47, 67, 0.16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button, input { font: inherit; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(480px, 1.08fr) minmax(440px, 0.92fr);
}

.auth-context {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px clamp(32px, 5vw, 76px);
  overflow: hidden;
  border-right: 1px solid var(--border);
  background-color: var(--bg);
  background-image:
    linear-gradient(color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px);
  background-size: 48px 48px;
}

.auth-context::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 24%, transparent 76%, var(--bg) 100%);
}

.auth-brand, .auth-context-footer, .auth-story { position: relative; z-index: 1; }

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-brand > span:last-child {
  margin-left: 3px;
  padding-left: 13px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: repeat(3, 4px);
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding-bottom: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 55%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--primary) 14%, var(--panel));
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--primary) 12%, transparent);
}

.brand-mark i { display: block; width: 4px; border-radius: 3px; background: var(--primary); }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; background: var(--ai); }
.brand-mark i:nth-child(3) { height: 11px; }
.brand-mark.small { width: 28px; height: 28px; padding-bottom: 6px; }

.auth-story {
  width: min(620px, 100%);
  margin: auto 0;
  padding: 72px 0;
}

.auth-kicker {
  color: var(--ai);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.auth-story h1 {
  max-width: 620px;
  margin: 18px 0 20px;
  font-size: 62px;
  line-height: 1.02;
  font-weight: 720;
}

.auth-story > p {
  max-width: 570px;
  margin: 0;
  color: var(--secondary);
  font-size: 17px;
  line-height: 1.65;
}

.workflow-preview {
  width: min(560px, 100%);
  margin-top: 44px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.preview-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
}

.preview-head strong, .preview-head small { display: block; }
.preview-head small { margin-top: 3px; color: var(--muted); }

.agent-orbit {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ai);
  border-right-color: transparent;
  border-radius: 50%;
  animation: orbit 4s linear infinite;
}

.agent-orbit i { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--secondary);
  font-family: var(--mono);
  font-size: 11px;
}

.live-badge i, .status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); }

.preview-progress { height: 3px; margin: 17px 0; overflow: hidden; background: var(--surface); }
.preview-progress span { display: block; width: 68%; height: 100%; background: var(--primary); }

.preview-steps { display: grid; gap: 3px; }
.preview-steps > div { min-height: 34px; display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0 8px; color: var(--secondary); }
.preview-steps i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.preview-steps .done i { background: #22c55e; }
.preview-steps .current { border-radius: 6px; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text); }
.preview-steps .current i { background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.preview-steps small { color: var(--muted); font-family: var(--mono); }

.auth-context-footer {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.auth-context-footer span:first-child { display: flex; align-items: center; gap: 8px; }

.auth-panel {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.theme-button {
  position: absolute;
  top: 26px;
  right: 26px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
  cursor: pointer;
}

.theme-button svg,
.submit-button svg {
  width: 17px;
  height: 17px;
  display: block;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-sun { display: none !important; }
:root[data-theme="light"] .theme-moon { display: none; }
:root[data-theme="light"] .theme-sun { display: block !important; }

.auth-form-wrap { width: min(420px, calc(100% - 48px)); margin: auto; }
.auth-heading { margin-bottom: 32px; }
.auth-heading > p { margin: 0 0 9px; color: var(--primary); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.auth-heading h2 { margin: 0; font-size: 30px; line-height: 1.15; }
.auth-heading > span:last-child { display: block; margin-top: 10px; color: var(--muted); }
.mobile-brand { display: none; }

#loginForm { display: grid; gap: 18px; }
#loginForm label { display: grid; gap: 8px; color: var(--secondary); font-size: 13px; font-weight: 650; }
#loginForm input {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

#loginForm input:focus { border-color: var(--primary); background: var(--panel); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }

.password-field { position: relative; }
.password-field input { padding-right: 88px !important; }
.password-field button { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); min-height: 34px; padding: 0 9px; border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 700; cursor: pointer; }

.auth-error { padding: 11px 12px; border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--border)); border-radius: 7px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-size: 13px; }

.submit-button {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 750;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

.submit-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.submit-button i { display: grid; place-items: center; }
.submit-button:disabled { cursor: wait; opacity: 0.75; transform: none; }
.submit-button.loading i { animation: nudge 850ms ease-in-out infinite; }

.first-login { display: grid; gap: 5px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.first-login strong { color: var(--secondary); font-size: 13px; }
.first-login code { color: var(--secondary); font-family: var(--mono); }

.auth-panel-footer { margin-top: auto; padding: 28px; color: var(--muted); font-size: 11px; text-align: center; }

@keyframes orbit { to { transform: rotate(1turn); } }
@keyframes nudge { 50% { transform: translateX(4px); } }

@media (max-width: 920px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-context { display: none; }
  .auth-panel { min-height: 100vh; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 72px; color: var(--text); font-weight: 750; }
}

@media (max-width: 1120px) and (min-width: 921px) {
  .auth-story h1 { font-size: 50px; }
}

@media (max-width: 520px) {
  .auth-form-wrap { width: min(100% - 32px, 420px); }
  .theme-button { top: 18px; right: 16px; }
  .mobile-brand { margin-bottom: 50px; }
  .auth-heading h2 { font-size: 26px; }
  .auth-panel-footer { padding: 20px 16px; }
}

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