*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #eef2fb;
  --surface: #ffffff;
  --surface-soft: #f7f9fe;
  --border: #dbe3f2;
  --border-strong: #c3d0e8;
  --text: #101a33;
  --text-muted: #5a6987;
  --text-soft: #7a88a5;
  --brand: #2c5ce6;
  --accent: #7c3aed;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-border: #6ee7b7;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --err-border: #fca5a5;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --ring: rgba(44, 92, 230, 0.18);
  --shadow-md: 0 10px 30px -12px rgba(16, 26, 51, 0.22);
  --shadow-lg: 0 28px 60px -28px rgba(16, 26, 51, 0.34);
  --radius: 14px;
  --radius-lg: 22px;
  --field-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1f;
    --surface: #131b2f;
    --surface-soft: #182135;
    --border: #27324a;
    --border-strong: #36435f;
    --text: #eef2fb;
    --text-muted: #9fadc8;
    --text-soft: #7c8aa6;
    --brand: #5b8bff;
    --accent: #a78bfa;
    --ok: #6ee7b7;
    --ok-bg: rgba(6, 95, 70, 0.22);
    --ok-border: rgba(110, 231, 183, 0.42);
    --err: #fca5a5;
    --err-bg: rgba(153, 27, 27, 0.22);
    --err-border: rgba(252, 165, 165, 0.42);
    --warn: #fcd34d;
    --warn-bg: rgba(146, 64, 14, 0.22);
    --warn-border: rgba(252, 211, 77, 0.42);
    --ring: rgba(91, 139, 255, 0.26);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 28px 60px -28px rgba(0, 0, 0, 0.75);
  }
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, Inter, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(820px 420px at 12% -12%, rgba(44, 92, 230, 0.16), transparent 62%),
    radial-gradient(720px 380px at 92% 4%, rgba(124, 58, 237, 0.14), transparent 60%),
    radial-gradient(760px 500px at 50% 108%, rgba(14, 165, 233, 0.1), transparent 62%);
}

.container {
  width: min(560px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 48px) clamp(16px, 4vw, 24px) 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Header ---------- */

.hero {
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--accent));
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 4.4vw, 1.6rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.hero-sub {
  margin: 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  max-width: 42ch;
}

/* ---------- Card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4.5vw, 30px);
  box-shadow: var(--shadow-lg);
}

form {
  display: grid;
  gap: 17px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label,
.field-label {
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ---------- Inputs ---------- */

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.input-icon {
  position: absolute;
  left: 15px;
  width: 18px;
  height: 18px;
  color: var(--text-soft);
  pointer-events: none;
  transition: color 0.18s ease;
}

input,
select {
  width: 100%;
  min-height: var(--field-h);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface-soft);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.input-wrap input {
  padding-left: 44px;
}

.input-wrap.has-toggle input {
  padding-right: 50px;
}

select {
  appearance: none;
  padding-right: 44px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6987' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 18px;
}

input::placeholder {
  color: var(--text-soft);
}

input:focus,
select:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

.input-wrap:focus-within .input-icon {
  color: var(--brand);
}

input[readonly] {
  color: var(--text-muted);
  cursor: default;
}

input[readonly]:focus {
  border-color: var(--border-strong);
  box-shadow: none;
}

input:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* password visibility toggle */

.toggle-visibility {
  position: absolute;
  right: 7px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0;
  transition: color 0.18s ease, background-color 0.18s ease;
}

.toggle-visibility:hover {
  color: var(--brand);
  background: var(--ring);
}

.toggle-visibility:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.toggle-visibility svg {
  width: 19px;
  height: 19px;
}

.toggle-visibility .icon-hide {
  display: none;
}

.toggle-visibility[aria-pressed="true"] .icon-hide {
  display: block;
}

.toggle-visibility[aria-pressed="true"] .icon-show {
  display: none;
}

/* ---------- Username row ---------- */

.username-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: stretch;
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary,
.search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--field-h);
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  box-shadow: var(--shadow-md);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn-primary {
  width: 100%;
  margin-top: 4px;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
}

.search-btn {
  padding: 0 20px;
  font-size: 0.94rem;
  white-space: nowrap;
  background: var(--surface-soft);
  color: var(--brand);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.search-btn:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--ring);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px -14px rgba(44, 92, 230, 0.7);
}

.btn-primary:active:not(:disabled),
.search-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary:focus-visible,
.search-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

form.is-submitting button {
  cursor: wait;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2.2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

.search-btn .spinner {
  border-color: var(--ring);
  border-top-color: var(--brand);
}

/* ---------- Password strength ---------- */

.strength {
  display: grid;
  gap: 7px;
  margin-top: 1px;
}

.strength[hidden] {
  display: none;
}

.strength-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--err);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-fill[data-level="1"] { width: 25%; background: #ef4444; }
.strength-fill[data-level="2"] { width: 50%; background: #f59e0b; }
.strength-fill[data-level="3"] { width: 75%; background: #3b82f6; }
.strength-fill[data-level="4"] { width: 100%; background: #10b981; }

.strength-label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-muted);
}

.checks {
  display: grid;
  gap: 5px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.checks li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text-soft);
  transition: color 0.18s ease;
}

.checks li::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  border: 1.6px solid var(--border-strong);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 10px;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.checks li.pass {
  color: var(--ok);
}

.checks li.pass::before {
  border-color: var(--ok);
  background-color: var(--ok);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* inline match hint */

.hint {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
}

.hint[hidden] {
  display: none;
}

.hint.is-error {
  color: var(--err);
}

.hint.is-ok {
  color: var(--ok);
}

/* ---------- Result banners ---------- */

.ok,
.error,
.warn {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 17px;
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.5;
  animation: slideIn 0.26s ease;
}

.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok);
}

.error {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err);
}

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  flex-direction: column;
  gap: 6px;
}

.warn-list {
  margin: 0;
  padding-left: 20px;
  font-weight: 500;
}

.warn-list li {
  margin-top: 3px;
}

.ok::before,
.error::before {
  content: "";
  width: 19px;
  height: 19px;
  flex: none;
  margin-top: 1px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.ok::before {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23047857' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.8 10A10 10 0 1 1 17 3.34'/%3E%3Cpath d='m9 11 3 3L22 4'/%3E%3C/svg%3E");
}

.error::before {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b91c1c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v5'/%3E%3Cpath d='M12 16h.01'/%3E%3C/svg%3E");
}

/* ---------- Footer ---------- */

.support-note {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted);
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.support-note svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--brand);
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .username-search-row {
    grid-template-columns: 1fr;
  }

  .card {
    border-radius: 18px;
  }
}

/* ---------- Motion ---------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
