:root {
  color-scheme: light;
  --auth-bg: #ffffff;
  --auth-dots: #f0f3f8;
  --auth-card: #ffffff;
  --auth-text: #1f2937;
  --auth-ink: #e1edff;
  --auth-ink-hover: #d8e7ff;
  --auth-ink-border: #c7dcff;
  --auth-ink-border-hover: #b3cffd;
  --auth-on-ink: #1a5fd8;
  --auth-muted: #6b7280;
  --auth-border: #e8ebf0;
  --auth-input-border: #dfe3ea;
  --auth-input-hover: #cdd3dc;
  --auth-focus: #93b8f8;
  --auth-focus-ring: rgba(37, 99, 235, .14);
  --auth-shadow: 0 1px 2px rgba(15, 23, 42, .02), 0 18px 44px -20px rgba(15, 23, 42, .14);
  --auth-accent: #2563eb;
  --auth-dot: #4a8af4;
  --auth-button-shadow: 0 6px 16px -10px rgba(37, 99, 235, .45);
  --auth-red: #dc2626;
  --auth-red-soft: rgba(220, 38, 38, .06);
  --auth-red-line: rgba(220, 38, 38, .3);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
/* Dark is opt-in from the workspace toggle; white stays the default. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --auth-bg: #0a0c10;
  --auth-dots: #1b2029;
  --auth-card: #12151b;
  --auth-text: #e6eaf0;
  --auth-ink: #1b2c4d;
  --auth-ink-hover: #213866;
  --auth-ink-border: #2c4a80;
  --auth-ink-border-hover: #3a5c9c;
  --auth-on-ink: #bcd4ff;
  --auth-muted: #838c9a;
  --auth-border: #232833;
  --auth-input-border: #2c3340;
  --auth-input-hover: #3d4555;
  --auth-focus: #4f86ea;
  --auth-focus-ring: rgba(111, 163, 255, .16);
  --auth-shadow: none;
  --auth-accent: #7fb0ff;
  --auth-dot: #6fa3ff;
  --auth-button-shadow: 0 6px 16px -10px rgba(0, 0, 0, .6);
  --auth-red: #f87171;
  --auth-red-soft: rgba(248, 113, 113, .12);
  --auth-red-line: rgba(248, 113, 113, .4);
}

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

body {
  margin: 0;
  color: var(--auth-text);
  background-color: var(--auth-bg);
  background-image: radial-gradient(circle at 1px 1px, var(--auth-dots) .8px, transparent 0);
  background-size: 20px 20px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible { outline: 2px solid var(--auth-accent); outline-offset: 2px; }
::selection { background: var(--auth-accent); color: #fff; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes dot-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

.signin-layout {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 32px 16px;
}

.signin-card {
  width: 100%;
  max-width: 380px;
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--auth-border);
  border-radius: 20px;
  background: var(--auth-card);
  box-shadow: var(--auth-shadow);
  animation: rise .6s var(--ease-out) backwards;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.signin-header { margin-bottom: 24px; }

.signin-header h1 {
  display: inline-block;
  margin: 0;
  font: 900 34px/1.05 'Doto', 'JetBrains Mono', monospace;
  letter-spacing: -.01em;
  animation: dot-reveal .8s steps(18, end) .25s backwards;
}

.signin-header h1 span { display: inline; }

.signin-header h1::after {
  content: "";
  display: inline-block;
  width: .2em;
  height: .2em;
  margin-left: .1em;
  border-radius: 50%;
  background: var(--auth-dot);
  animation: blink .9s steps(1) 1.05s 2;
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.password-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--auth-muted);
  font: 500 11.5px/1.4 'JetBrains Mono', monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.password-control {
  display: flex;
  align-items: stretch;
  min-height: 46px;
  border: 1px solid var(--auth-input-border);
  border-radius: 12px;
  background: var(--auth-card);
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out);
}

.password-control:hover { border-color: var(--auth-input-hover); }

.password-control:focus-within {
  border-color: var(--auth-focus);
  box-shadow: 0 0 0 4px var(--auth-focus-ring);
}

.password-control input {
  display: block;
  flex: 1;
  width: 0;
  min-width: 0;
  padding: 11px 0 11px 14px;
  border: 0;
  border-radius: 12px 0 0 12px;
  outline: none;
  background: transparent;
  color: var(--auth-text);
  font-size: 16px;
  line-height: 22px;
}

.password-control input::placeholder {
  color: var(--auth-muted);
  font-size: 14px;
}

.password-toggle {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 46px;
  padding: 0;
  border: 0;
  border-radius: 0 12px 12px 0;
  color: var(--auth-muted);
  background: transparent;
  transition: color .18s var(--ease-out);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-slash { display: none; }
.password-toggle[aria-pressed="true"] .password-slash { display: block; }
.password-toggle:hover { color: var(--auth-text); }
.password-toggle:focus-visible { outline-offset: -4px; }

.signin-submit {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 20px;
  border: 1px solid var(--auth-ink-border);
  border-radius: 12px;
  background: var(--auth-ink);
  color: var(--auth-on-ink);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 20px;
  transition: background .18s var(--ease-out), border-color .18s var(--ease-out), transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
}

.signin-submit svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .25s var(--ease-out);
}

.signin-submit:hover { background: var(--auth-ink-hover); border-color: var(--auth-ink-border-hover); transform: translateY(-1px); box-shadow: var(--auth-button-shadow); }
.signin-submit:hover svg { transform: translateX(3px); }
.signin-submit:active { transform: translateY(1px) scale(.98); box-shadow: none; }

.signin-error {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -2px;
  padding: 9px 12px;
  border: 1px solid var(--auth-red-line);
  border-radius: 10px;
  background: var(--auth-red-soft);
  color: var(--auth-red);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  animation: shake .4s var(--ease-out) .5s;
}

.signin-error::before { content: ""; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--auth-red); animation: blink .8s steps(1) .9s 2; }

.password-control.has-error { border-color: var(--auth-red); }
.password-control.has-error:focus-within { box-shadow: 0 0 0 4px var(--auth-red-soft); }

@media (max-width: 480px) {
  .signin-card { padding: 24px 20px 20px; border-radius: 18px; }
  .signin-header h1 { font-size: 30px; }
}

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