:root {
  color-scheme: dark;
  --bg: #0c0913;
  --bg-soft: #120d1d;
  --surface: #18112a;
  --surface-2: #1f1735;
  --surface-3: #2a2046;
  --border: #2b2244;
  --border-strong: #3a2e5c;
  --text: #eeeaf7;
  --muted: #a39bbd;
  --faint: #756c95;
  --accent: #8b5cf6;
  --accent-hi: #b197fc;
  --accent-lo: #6d28d9;
  --accent-glow: rgba(139, 92, 246, .38);
  --danger: #f87171;
  --ok: #4ade80;
  --font: 'Manrope', 'Noto Color Emoji', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --emoji: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 12% -12%, rgba(124, 58, 237, .30), transparent 60%),
    radial-gradient(700px 520px at 108% 18%, rgba(168, 85, 247, .16), transparent 60%),
    radial-gradient(800px 600px at 50% 125%, rgba(91, 33, 182, .26), transparent 60%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(177, 151, 252, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(177, 151, 252, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%);
}

a { color: var(--accent-hi); }
::selection { background: rgba(139, 92, 246, .45); color: #fff; }

/* ---------- Логотип ---------- */

.logo {
  display: inline-flex;
  align-items: center;
  font: 700 22px/1 var(--mono);
  letter-spacing: -.03em;
  color: var(--text);
  text-decoration: none;
}
.logo-dot { color: var(--accent-hi); }

.caret {
  display: inline-block;
  width: .5em;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: middle;
  background: var(--accent-hi);
  border-radius: 1px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: 600 15px/1 var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s, border-color .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .input:focus-visible, .icon-btn:focus-visible, .pw-toggle:focus-visible, .logo:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; border-radius: 10px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #9468ff 0%, #7c3aed 100%);
  box-shadow: 0 10px 28px -10px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn-primary:hover { background: linear-gradient(180deg, #a07aff 0%, #8445f2 100%); box-shadow: 0 14px 34px -10px rgba(139, 92, 246, .6), inset 0 1px 0 rgba(255, 255, 255, .22); }

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, .02);
  border-color: var(--border-strong);
}
.btn-ghost:hover { border-color: #56438a; background: rgba(139, 92, 246, .08); }

.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Лендинг ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 22px 24px;
}
.site-nav { display: flex; gap: 10px; }

.hero {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 56px;
  align-items: center;
  max-width: 1160px;
  margin: 0 auto;
  padding: 64px 24px 56px;
}

.eyebrow {
  display: inline-block;
  padding: 6px 12px;
  font: 500 13px/1.3 var(--mono);
  color: var(--accent-hi);
  background: rgba(139, 92, 246, .1);
  border: 1px solid rgba(139, 92, 246, .28);
  border-radius: 999px;
}

.hero h1 {
  margin: 22px 0 18px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.04;
  font-weight: 800;
  letter-spacing: -.035em;
}
.grad {
  background: linear-gradient(90deg, #d8ccff 0%, #9d74ff 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { max-width: 520px; margin: 0; font-size: 18px; color: var(--muted); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.mock {
  overflow: hidden;
  font: 14px/1.45 var(--mono);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .75), 0 30px 120px -40px var(--accent-glow);
}
.mock-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .015);
  border-bottom: 1px solid var(--border);
}
.mock-bar span { width: 11px; height: 11px; border-radius: 50%; background: var(--surface-3); }
.mock-bar em { margin-left: 10px; font-style: normal; font-size: 12.5px; color: var(--faint); }
.mock-body { display: flex; flex-direction: column; gap: 10px; min-height: 280px; padding: 22px 18px; }

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  opacity: 0;
  animation: pop .45s ease-out forwards;
}
.msg:nth-child(1) { animation-delay: .2s; }
.msg:nth-child(2) { animation-delay: .9s; }
.msg:nth-child(3) { animation-delay: 1.6s; }
.msg:nth-child(4) { animation-delay: 2.3s; }
.msg:nth-child(5) { animation-delay: 3s; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.msg.in { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; color: #fff; background: linear-gradient(180deg, #8657f6, #6d28d9); border-bottom-right-radius: 4px; }
.msg .who { display: block; margin-bottom: 2px; font-size: 11.5px; color: var(--accent-hi); }
.msg.typing { display: flex; gap: 4px; padding: 13px 14px; }
.msg.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite ease-in-out; }
.msg.typing i:nth-child(2) { animation-delay: .15s; }
.msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.mock-input { padding: 14px 18px; color: var(--faint); border-top: 1px solid var(--border); }
.mock-input .caret { height: 1em; margin-left: 4px; }

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px 24px 80px;
}
.feature {
  padding: 24px;
  background: rgba(24, 17, 42, .6);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color .2s, transform .2s;
}
.feature:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.feature-ic { font: 600 13px var(--mono); color: var(--accent-hi); }
.feature h3 { margin: 10px 0 6px; font-size: 18px; letter-spacing: -.01em; }
.feature p { margin: 0; font-size: 15px; color: var(--muted); }

.site-footer { padding: 24px; font-size: 14px; text-align: center; color: var(--faint); border-top: 1px solid var(--border); }

/* ---------- Вход и регистрация ---------- */

.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 16px;
}
.auth > .logo { margin-bottom: 26px; font-size: 30px; }

.card {
  width: 100%;
  max-width: 430px;
  padding: 34px 30px 28px;
  background: linear-gradient(180deg, rgba(31, 23, 53, .88), rgba(19, 13, 32, .92));
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .02) inset, 0 30px 120px -60px var(--accent-glow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.card h1 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.card .sub { margin: 0 0 24px; font-size: 15px; color: var(--muted); }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-size: 13.5px; font-weight: 600; color: #d3cce8; }

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font: 15px var(--font);
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: #4b3c76; }
.input:focus { border-color: var(--accent); background: #150f23; box-shadow: 0 0 0 4px rgba(139, 92, 246, .18); }
.input:disabled { opacity: .55; cursor: not-allowed; }
.input-sm { height: 40px; font-size: 14px; border-radius: 10px; }
.field.has-error .input { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 4px rgba(248, 113, 113, .15); }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap.has-prefix .input { padding-left: 32px; padding-right: 14px; }
.input-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font: 500 15px var(--mono);
  color: var(--faint);
  pointer-events: none;
}

.pw-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--faint);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle .off, .pw-toggle.is-on .on { display: none; }
.pw-toggle.is-on .off { display: block; }

.hint { margin-top: 6px; font-size: 12.5px; color: var(--faint); }
.field-error { margin-top: 6px; font-size: 13px; color: var(--danger); }
.field-error[hidden] { display: none; }

.strength { display: flex; align-items: center; gap: 4px; margin-top: 9px; }
.strength i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); transition: background .25s; }
.strength-label { min-width: 72px; margin-left: 8px; font-size: 12px; text-align: right; color: var(--faint); }
.strength[data-level="1"] i:nth-child(-n+1) { background: #f87171; }
.strength[data-level="2"] i:nth-child(-n+2) { background: #fb923c; }
.strength[data-level="3"] i:nth-child(-n+3) { background: #a78bfa; }
.strength[data-level="4"] i:nth-child(-n+4) { background: #4ade80; }

.alert { margin-bottom: 18px; padding: 12px 14px; font-size: 14px; border: 1px solid; border-radius: 12px; }
.alert-error { color: #fecaca; background: rgba(248, 113, 113, .08); border-color: rgba(248, 113, 113, .3); }

.card .btn-block { margin-top: 8px; }

.auth-switch { margin: 22px 0 0; font-size: 14.5px; text-align: center; color: var(--muted); }
.auth-switch a { font-weight: 700; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.back { margin-top: 22px; font-size: 14px; color: var(--faint); text-decoration: none; }
.back:hover { color: var(--muted); }

/* ---------- Адаптив ---------- */

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 32px; }
  .features { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header { padding: 16px; }
  .hero, .features { padding-left: 16px; padding-right: 16px; }
  .site-nav .btn-ghost { display: none; }
  .cta .btn { width: 100%; }
  .card { padding: 26px 20px 22px; border-radius: 18px; }
}

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