:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #171a26;
  --muted: #6b7280;
  --border: #e6e8f0;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(23, 26, 38, .08);
  --shadow-lg: 0 18px 50px rgba(23, 26, 38, .12);
}

* { box-sizing: border-box; }

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- Фон ---------- */

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 80% -10%, #e7e9ff 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 20%, #fde8ff 0%, transparent 55%),
    var(--bg);
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  animation: drift 18s ease-in-out infinite alternate;
}

.bg-blob--1 { width: 340px; height: 340px; background: #c7d2fe; top: -80px; right: 8%; }
.bg-blob--2 { width: 260px; height: 260px; background: #fbcfe8; bottom: -60px; left: 6%; animation-delay: -6s; }
.bg-blob--3 { width: 200px; height: 200px; background: #bbf7d0; top: 40%; left: 30%; opacity: .35; animation-delay: -12s; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(30px, -20px, 0) scale(1.08); }
}

/* ---------- Шапка ---------- */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .02em;
}

.logo__mark { font-size: 20px; }
.logo__text { font-size: 18px; }

.app-bar__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-bar__profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-bar__nick {
  font-weight: 600;
  font-size: 14px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  user-select: none;
}

/* ---------- Переключатель языка ---------- */

.lang-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--accent-soft);
  border-radius: 999px;
}

.lang-switch__btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.lang-switch__btn:hover { color: var(--text); }

.lang-switch__btn.is-active {
  background: var(--card);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(23, 26, 38, .12);
}

/* ---------- Страница ---------- */

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 20px 24px;
}

.screen { animation: fade-in .25s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Карточка ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-card {
  max-width: 420px;
  margin: 24px auto 0;
}

.card__title {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.2;
}

.card__subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.card__hint {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Переключатель Вход/Регистрация ---------- */

.auth-switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-switch__thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--card);
  border-radius: 9px;
  box-shadow: 0 1px 5px rgba(23, 26, 38, .15);
  transition: transform .2s ease;
}

.auth-switch[data-mode="register"] .auth-switch__thumb { transform: translateX(100%); }

.auth-switch__option {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  padding: 8px 0;
  cursor: pointer;
  border-radius: 9px;
  transition: color .15s ease;
}

.auth-switch__option.is-active { color: var(--text); }

/* ---------- Форма ---------- */

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

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

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field__input {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fafbfe;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field__input::placeholder { color: #a6abb8; }

.field__input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

.field__hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.field__error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  min-height: 14px;
}

.form__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 13px;
}

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

.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: .6;
  cursor: default;
}

.btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 8px 22px rgba(79, 70, 229, .45);
}

.btn--ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.btn--ghost:hover:not(:disabled) { background: #f6f7fb; }

.btn--lg { width: 100%; padding: 13px 18px; font-size: 15px; }
.btn--sm { padding: 6px 12px; font-size: 13px; }

.link-button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

/* ---------- Дашборд ---------- */

.dashboard__title {
  margin: 0 0 6px;
  font-size: 30px;
}

.dashboard__subtitle {
  margin: 0 0 28px;
  color: var(--muted);
  max-width: 560px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.module-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.module-card__icon {
  font-size: 30px;
  display: inline-block;
  margin-bottom: 10px;
}

.module-card__title {
  margin: 0 0 6px;
  font-size: 17px;
}

.module-card__desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

/* ---------- Футер ---------- */

.page-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 12px;
}


/* ---------- Профиль ---------- */

.profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  border-radius: 999px;
  padding: 2px 10px 2px 2px;
  transition: background .15s ease;
}
.profile-link:hover { background: var(--accent-soft); }
.profile-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.profile-back {
  display: inline-block;
  margin-bottom: 16px;
  text-decoration: none;
}

#screen-profile {
  max-width: 420px;
  margin: 0 auto;

}

.profile-card { text-align: center; }

.avatar--lg {
  width: 88px;
  height: 88px;
  font-size: 38px;
  margin-bottom: 14px;
}

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

@media (max-width: 640px) {
  .app-bar { padding: 10px 14px; }
  .page { padding: 28px 14px 16px; }
  .card { padding: 22px; }
  .card__title { font-size: 22px; }
  .dashboard__title { font-size: 24px; }
  .app-bar__nick { display: none; }
  .profile-link { padding: 2px; }

  /* Шапка в одну строку на ~360px: прячем текст логотипа, ужимаем отступы */
  .logo__text { display: none; }
  .app-bar__right, .app-bar__profile { gap: 8px; }
  .lang-switch__btn { padding: 5px 8px; }
  .avatar { width: 30px; height: 30px; font-size: 13px; }

  /* Карточки модулей: компактная строка «иконка | текст», бейдж справа */
  .module-grid { grid-template-columns: 1fr; gap: 12px; }
  .module-card {
    display: grid;
    grid-template-columns: 44px 1fr;
    column-gap: 14px;
    align-items: center;
    padding: 16px 16px 16px 14px;
  }
  .module-card:hover { transform: none; }
  .module-card__icon { grid-row: span 2; margin: 0; font-size: 28px; text-align: center; }
  .module-card__title { margin: 0 64px 2px 0; font-size: 16px; }
  .module-card__desc { grid-column: 2; }
  .badge { top: 14px; right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-blob { animation: none; }
  .screen { animation: none; }
}
