/* ChipPilot login - handoff implementation */

:root {
  --bg: #08080a;
  --bg-1: #0c0c10;
  --bg-2: #111116;
  --bg-3: #16161c;
  --surface: #0f0f14;
  --surface-2: #15151c;
  --border: #22222a;
  --border-1: #1a1a22;
  --border-2: #2c2c36;
  --hairline: #1d1d25;
  --fg: #f3f3f5;
  --fg-1: #d9d9de;
  --fg-2: #9b9ba3;
  --fg-3: #6c6c76;
  --fg-4: #4a4a52;
  --acc: #c5f24a;
  --acc-2: #d4f86b;
  --acc-ink: #0a0c00;
  --acc-soft: rgba(197, 242, 74, 0.12);
  --acc-line: rgba(197, 242, 74, 0.32);
  --ok: #c5f24a;
  --info: #7cc4ff;
  --warn: #f5b13a;
  --err: #ff6f6f;
  --proved: #8ab4ff;
  --f-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 8px;
  --shadow-2: 0 30px 60px -30px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border);
}

:root[data-accent="lime"] {
  --acc: #c5f24a;
  --acc-2: #d4f86b;
  --acc-ink: #0a0c00;
  --acc-soft: rgba(197, 242, 74, 0.12);
  --acc-line: rgba(197, 242, 74, 0.32);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  color: var(--fg);
  font-family: var(--f-sans);
  font-feature-settings: "ss01", "cv11", "cv02";
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

svg {
  display: block;
}

.auth-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
  min-height: 100svh;
}

.auth-context {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: 32px 48px;
  overflow: hidden;
  border-right: 1px solid var(--hairline);
  background:
    radial-gradient(ellipse 80% 50% at 30% 20%, color-mix(in srgb, var(--acc) 6%, transparent), transparent 70%),
    var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-context::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--acc), transparent);
  opacity: 0.4;
  animation: auth-scan 6s ease-in-out infinite;
  pointer-events: none;
}

.die {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.8;
}

.die svg {
  width: 100%;
  height: 100%;
}

.pin-a {
  animation: pin-grow 2.2s ease-in-out infinite;
  transform-origin: 350px 500px;
}

.pin-b {
  animation: pin-opacity 3.4s ease-in-out infinite;
}

.pin-c {
  animation: pin-opacity 1.8s ease-in-out infinite;
}

.ac-top,
.ac-tag,
.ac-ops {
  position: relative;
  z-index: 2;
}

.ac-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  font-family: var(--f-mono);
  font-size: 14.5px;
  letter-spacing: 0.02em;
}

.logo-mark {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}

.logo .ver {
  padding: 1px 6px;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.ac-top .logo .ver {
  border-color: var(--acc-line);
  color: var(--acc);
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.led {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--acc);
  box-shadow: 0 0 8px var(--acc);
  animation: auth-pulse 1.6s ease-in-out infinite;
}

.led--ok {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.kicker {
  color: var(--fg-2);
  font-family: var(--f-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kicker .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 10px;
  border-radius: 999px;
  background: var(--acc);
  transform: translateY(-1px);
}

.ac-tag {
  max-width: 520px;
}

.ac-tag .kicker {
  margin-bottom: 22px;
}

.ac-tag h2 {
  margin: 0;
  color: var(--fg);
  font-size: clamp(32px, 3.4vw, 46px);
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.02;
}

.acc-word {
  color: var(--acc);
  font-style: italic;
  font-weight: 400;
}

.acc-word::before {
  content: "/* ";
  margin-right: 4px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 0.42em;
  font-style: normal;
  vertical-align: 0.6em;
}

.acc-word::after {
  content: " */";
  margin-left: 4px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 0.42em;
  font-style: normal;
  vertical-align: 0.6em;
}

.ac-tag p {
  max-width: 48ch;
  margin: 18px 0 0;
  color: var(--fg-2);
  font-size: 14.5px;
}

.ac-ops {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ops-head > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ops-head .right {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.ops-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.ops-row {
  display: grid;
  grid-template-columns: 64px 1fr 90px 90px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--border-1);
  font-family: var(--f-mono);
  font-size: 12px;
}

.ops-row .id {
  color: var(--fg-3);
}

.ops-row .label {
  min-width: 0;
  overflow: hidden;
  color: var(--fg-1);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-row .bar {
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  background: var(--bg-3);
}

.ops-row .bar > i {
  display: block;
  height: 100%;
  background: var(--acc);
  box-shadow: 0 0 12px color-mix(in srgb, var(--acc) 60%, transparent);
  animation: auth-fill 1.6s cubic-bezier(.2, .7, .2, 1) both;
}

.ops-row .status {
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.ops-row .status.ok {
  color: var(--ok);
}

.ops-row .status.proved {
  color: var(--proved);
}

.ops-row .status.warn {
  color: var(--warn);
}

.ops-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-1);
  background: var(--bg-1);
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.auth-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 56px 40px 82px;
  background: var(--bg);
}

.auth-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--fg) 4%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--fg) 4%, transparent) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 90%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: 440px;
  flex-direction: column;
  gap: 28px;
}

.auth-card > * {
  opacity: 0;
  transform: translateY(8px);
  animation: auth-fadein 600ms cubic-bezier(.2, .7, .2, 1) forwards;
}

.auth-card > *:nth-child(1) { animation-delay: 40ms; }
.auth-card > *:nth-child(2) { animation-delay: 110ms; }
.auth-card > *:nth-child(3) { animation-delay: 180ms; }
.auth-card > *:nth-child(4) { animation-delay: 250ms; }
.auth-card > *:nth-child(5) { animation-delay: 320ms; }
.auth-card > *:nth-child(6) { animation-delay: 380ms; }
.auth-card > *:nth-child(7) { animation-delay: 430ms; }

.mobile-logo {
  display: none;
}

.auth-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-head h1 {
  margin: 0;
  color: var(--fg);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.04;
}

.auth-head p {
  max-width: 38ch;
  margin: 0;
  color: var(--fg-2);
  font-size: 14.5px;
}

.auth-sso {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sso-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sso-btn {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 48px;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg-1);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.sso-btn:hover {
  border-color: var(--fg-3);
  background: var(--bg-2);
}

.sso-btn:focus-visible,
.auth-cta:focus-visible,
.suffix:focus-visible,
.auth-request a:focus-visible,
.auth-legal a:focus-visible,
.field-head a:focus-visible,
.logo:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
}

.sso-btn.is-loading {
  pointer-events: none;
  border-color: var(--acc-line);
  color: var(--acc);
}

.sso-btn.is-loading::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: auto;
  border: 1px solid color-mix(in srgb, var(--acc) 34%, transparent);
  border-top-color: var(--acc);
  border-radius: 999px;
  animation: auth-spin 700ms linear infinite;
}

.sso-btn .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: currentColor;
}

.sso-btn span {
  white-space: nowrap;
}

.sso-btn--primary {
  border-color: var(--acc-line);
  background: var(--bg-2);
}

.sso-btn--primary .icon {
  color: var(--acc);
}

.sso-btn--primary .pill {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--acc-line);
  border-radius: 3px;
  background: var(--acc-soft);
  color: var(--acc);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.sso-row .sso-btn {
  justify-content: center;
}

.auth-alert {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  color: var(--fg-1);
  font-family: var(--f-mono);
  font-size: 12px;
  line-height: 1.5;
}

.auth-alert.error {
  border-color: color-mix(in srgb, var(--err) 42%, transparent);
  background: color-mix(in srgb, var(--err) 8%, transparent);
}

.auth-alert[hidden] {
  display: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.field-head .req {
  margin-left: 6px;
  color: var(--acc);
}

.field-head .hint {
  color: var(--fg-3);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.field-head a {
  color: var(--fg-2);
  transition: color 120ms ease;
}

.field-head a:hover {
  color: var(--acc);
}

.input-wrap {
  position: relative;
  display: flex;
  min-width: 0;
  align-items: center;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.input-wrap:hover {
  border-color: var(--fg-3);
}

.input-wrap:focus-within {
  border-color: var(--acc);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--acc-soft);
}

.input-wrap.valid {
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
}

.input-wrap.invalid {
  border-color: color-mix(in srgb, var(--err) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 12%, transparent);
}

.prefix {
  flex: 0 0 auto;
  padding: 0 4px 0 14px;
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 13px;
}

.input-wrap input {
  width: 100%;
  height: 48px;
  min-width: 0;
  flex: 1;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--f-mono);
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.input-wrap input::placeholder {
  color: var(--fg-4);
  letter-spacing: 0.04em;
}

.check {
  display: inline-flex;
  align-items: center;
  padding: 0 14px 0 4px;
  color: var(--ok);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 120ms ease, transform 120ms ease;
}

.check svg {
  width: 14px;
  height: 14px;
}

.input-wrap.valid .check {
  opacity: 1;
  transform: scale(1);
}

.suffix {
  flex: 0 0 auto;
  padding: 0 12px 0 4px;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 120ms ease;
}

.suffix:hover {
  color: var(--fg-1);
}

.field-error {
  color: var(--err);
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.field-error:empty {
  display: none;
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.opt-stay {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-2);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  user-select: none;
}

.opt-stay input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.opt-stay .box {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  background: var(--surface);
  transition: border-color 120ms ease, background 120ms ease;
}

.opt-stay .box svg {
  width: 10px;
  height: 10px;
  color: var(--acc-ink);
  opacity: 0;
}

.opt-stay:hover .box {
  border-color: var(--fg-3);
}

.opt-stay input:focus-visible + .box {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
}

.opt-stay input:checked + .box {
  border-color: var(--acc);
  background: var(--acc);
}

.opt-stay input:checked + .box svg {
  opacity: 1;
}

.opt-stay input:checked + .box + .lbl {
  color: var(--fg-1);
}

.auth-cta {
  display: flex;
  width: 100%;
  height: 52px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  border: 1px solid var(--acc);
  border-radius: 8px;
  background: var(--acc);
  color: var(--acc-ink);
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: transform 120ms ease, background 120ms ease, box-shadow 200ms ease, opacity 120ms ease;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15) inset,
    0 12px 30px -10px color-mix(in srgb, var(--acc) 40%, transparent);
}

.auth-cta:not(:disabled):hover {
  background: var(--acc-2);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 16px 36px -10px color-mix(in srgb, var(--acc) 60%, transparent);
}

.auth-cta:disabled {
  cursor: not-allowed;
  filter: saturate(0.8);
}

.auth-cta.success {
  background: var(--acc-2);
}

.auth-cta .arr {
  width: 10px;
  height: 10px;
  border-top: 1.8px solid currentColor;
  border-right: 1.8px solid currentColor;
  transform: rotate(45deg) translate(-1px, 1px);
}

.cursor {
  display: inline-block;
  width: 6px;
  height: 1.05em;
  margin-left: 2px;
  background: var(--acc-ink);
  vertical-align: -2px;
  animation: auth-blink 1.05s steps(1) infinite;
}

.auth-foot {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 4px;
}

.auth-status {
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-1);
  border-radius: 6px;
  background: var(--bg-1);
}

.auth-status .item {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-right: 1px solid var(--border-1);
  color: var(--fg-3);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.auth-status .item:last-child {
  border-right: 0;
}

.auth-status .item .led {
  width: 6px;
  height: 6px;
}

.auth-request {
  color: var(--fg-2);
  font-size: 13px;
  text-align: center;
}

.auth-request a {
  padding-bottom: 1px;
  border-bottom: 1px dashed var(--acc-line);
  color: var(--acc);
}

.auth-request a:hover {
  border-bottom-color: var(--acc);
  color: var(--acc-2);
}

.auth-legal {
  position: absolute;
  right: 40px;
  bottom: 24px;
  left: 40px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--fg-4);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.auth-legal a {
  color: var(--fg-3);
}

.auth-legal a:hover {
  color: var(--fg-1);
}

@keyframes auth-scan {
  0% {
    opacity: 0;
    transform: translateY(8vh);
  }
  20% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh);
  }
}

@keyframes auth-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@keyframes pin-grow {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.2;
    transform: scale(1.7);
  }
}

@keyframes pin-opacity {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

@keyframes auth-fill {
  from {
    width: 0;
  }
}

@keyframes auth-fadein {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-blink {
  0%,
  60% {
    opacity: 1;
  }
  61%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 1120px) {
  .auth-context {
    padding: 30px 36px;
  }

  .ops-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .ops-row {
    grid-template-columns: 54px minmax(0, 1fr) 72px;
  }

  .ops-row .status {
    display: none;
  }
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-context {
    display: none;
  }

  .auth-panel {
    padding-top: 48px;
  }

  .mobile-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
  }
}

@media (max-width: 600px) {
  .auth-panel {
    align-items: flex-start;
    padding: 32px 20px 96px;
  }

  .auth-card {
    gap: 22px;
  }

  .auth-head h1 {
    font-size: 30px;
  }

  .sso-row {
    grid-template-columns: 1fr;
  }

  .sso-btn {
    padding: 0 14px;
    font-size: 11.5px;
  }

  .sso-btn--primary .pill {
    padding: 2px 6px;
    font-size: 9.5px;
  }

  .field-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .auth-status {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-status .item {
    border-right: 0;
    border-bottom: 1px solid var(--border-1);
  }

  .auth-status .item:last-child {
    border-bottom: 0;
  }

  .auth-legal {
    right: 20px;
    left: 20px;
    flex-direction: column;
    gap: 8px;
  }
}

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