:root {
  --bg: #f0f4f9;
  --card: #fff;
  --text: #1f1f1f;
  --muted: #444746;
  --link: #0b57d0;
  --border: #747775;
  --border-focus: #0b57d0;
  --error: #b3261e;
  --btn: #0b57d0;
  --btn-hover: #0e4eb5;
  --btn-text: #fff;
  --chip-border: #747775;
  --card-border: #c4c7c5;
  --hover-fill: rgba(60, 64, 67, 0.08);
  --link-hover-bg: rgba(11, 87, 208, 0.08);
  --menu-bg: #fff;
  --menu-border: #dadce0;
  --check: #1a73e8;
  --radius: 28px;
  --font: "Google Sans", "Roboto", Arial, Helvetica, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --slide: 420ms;
  color-scheme: light;
}

/* Авто-тема: Windows / браузер (media + data-theme из JS) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1f1f;
    --card: #0e0e0e;
    --text: #e3e3e3;
    --muted: #c4c7c5;
    --link: #a8c7fa;
    --border: #8e918f;
    --border-focus: #a8c7fa;
    --error: #f2b8b5;
    --btn: #a8c7fa;
    --btn-hover: #d3e3fd;
    --btn-text: #062e6f;
    --chip-border: #8e918f;
    --card-border: #444746;
    --hover-fill: rgba(232, 234, 237, 0.08);
    --link-hover-bg: rgba(168, 199, 250, 0.12);
    --menu-bg: #303030;
    --menu-border: #3c4043;
    --check: #8ab4f8;
    color-scheme: dark;
  }

  :root:not([data-theme="light"]) #maket-exam-watermark::before {
    color: rgba(232, 61, 69, 0.12);
  }
}

html[data-theme="dark"] {
  --bg: #1f1f1f;
  --card: #0e0e0e;
  --text: #e3e3e3;
  --muted: #c4c7c5;
  --link: #a8c7fa;
  --border: #8e918f;
  --border-focus: #a8c7fa;
  --error: #f2b8b5;
  --btn: #a8c7fa;
  --btn-hover: #d3e3fd;
  --btn-text: #062e6f;
  --chip-border: #8e918f;
  --card-border: #444746;
  --hover-fill: rgba(232, 234, 237, 0.08);
  --link-hover-bg: rgba(168, 199, 250, 0.12);
  --menu-bg: #303030;
  --menu-border: #3c4043;
  --check: #8ab4f8;
  color-scheme: dark;
}

html[data-theme="dark"] #maket-exam-watermark::before {
  color: rgba(232, 61, 69, 0.12);
}

html[data-theme="light"] {
  color-scheme: light;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  padding-top: 44px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* —— МАКЕТ —— */
#maket-exam-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 16px;
  background: #e83d45;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#maket-exam-banner .sub {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  opacity: 0.95;
  font-size: 13px;
}

#maket-exam-watermark {
  position: fixed;
  inset: 0;
  z-index: 2147483645;
  pointer-events: none;
  overflow: hidden;
}

#maket-exam-watermark::before {
  content: "МАКЕТ  ·  МАКЕТ  ·  МАКЕТ  ·  МАКЕТ  ·  МАКЕТ  ·  МАКЕТ  ·  МАКЕТ  ·  МАКЕТ";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200vmax;
  transform: translate(-50%, -50%) rotate(-28deg);
  font-size: clamp(42px, 6vw, 84px);
  font-weight: 800;
  letter-spacing: 0.35em;
  color: rgba(232, 61, 69, 0.08);
  white-space: nowrap;
  text-align: center;
}

.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 12px;
}

.card {
  width: 100%;
  max-width: 1080px;
  min-height: 460px;
  background: var(--card);
  border-radius: var(--radius);
  border: none;
  box-shadow: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 56px 48px 40px;
  overflow: hidden;
  position: relative;
}

.col-left {
  padding-right: 28px;
  position: relative;
}

.col-right {
  display: flex;
  flex-direction: column;
  padding-left: 16px;
  min-width: 0;
  position: relative;
}

.logo {
  width: 40px;
  height: 40px;
  margin-bottom: 18px;
  display: block;
}

.left-copy {
  transition: opacity var(--slide) var(--ease), transform var(--slide) var(--ease);
}

.left-copy.is-hidden {
  position: absolute;
  left: 0;
  right: 28px;
  top: 58px;
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
}

.left-copy.is-enter {
  opacity: 0;
  transform: translateX(12px);
}

h1 {
  margin: 0 0 16px;
  font-size: 44px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0;
  color: var(--text);
}

h1.h1-2fa {
  font-size: 36px;
}

/* —— Анимация устройства (2FA), как у Google —— */
.device-anim {
  position: relative;
  width: min(280px, 100%);
  height: 150px;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.device-anim-img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  display: block;
  animation: deviceFloat 2.8s ease-in-out infinite;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.18));
}

html[data-theme="dark"] .device-anim-img {
  filter: invert(0.92) hue-rotate(180deg) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
  opacity: 0.95;
}

.device-anim-notif {
  position: absolute;
  right: 18%;
  top: 22%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #1a73e8;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(26, 115, 232, 0.45);
  animation: notifPop 2.8s ease-in-out infinite;
  transform-origin: center;
}

.device-anim-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
  animation: dotBlink 1.4s ease-in-out infinite;
}

.device-anim-check {
  width: 16px;
  height: 16px;
  color: #34a853;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
  box-sizing: border-box;
  animation: checkIn 2.8s ease-in-out infinite;
}

.device-anim-check path {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  animation: checkDraw 2.8s ease-in-out infinite;
}

@keyframes deviceFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes notifPop {
  0%,
  12% {
    opacity: 0;
    transform: scale(0.6) translateY(8px);
  }
  28%,
  70% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  85%,
  100% {
    opacity: 0.85;
    transform: scale(0.98) translateY(-2px);
  }
}

@keyframes checkIn {
  0%,
  30% {
    opacity: 0;
    transform: scale(0.5);
  }
  45%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes checkDraw {
  0%,
  35% {
    stroke-dashoffset: 28;
  }
  55%,
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes dotBlink {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .device-anim-img,
  .device-anim-notif,
  .device-anim-check,
  .device-anim-check path,
  .device-anim-dot {
    animation: none !important;
  }
  .device-anim-notif,
  .device-anim-check {
    opacity: 1;
    transform: none;
  }
  .device-anim-check path {
    stroke-dashoffset: 0;
  }
}

.verify-device-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

.verify-device-text {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.verify-device-text.secondary {
  color: var(--muted);
  margin-bottom: 28px;
}

.verify-or {
  margin: 8px 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.verify-check {
  margin-top: 18px;
}

.verify-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 8px;
}

.verify-links .link {
  margin-top: 8px;
}

#otp {
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}

.subtitle {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.5;
  max-width: 22em;
}

#left-verify .account-chip {
  margin-top: 8px;
  margin-bottom: 0;
}

#left-verify .subtitle {
  margin-top: 20px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 3px 10px 3px 3px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  max-width: 100%;
}

.account-chip:hover {
  background: var(--hover-fill);
}

.account-chip .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #7b1fa2;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.account-chip .email-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.account-chip .caret {
  flex-shrink: 0;
  color: var(--muted);
}

/* steps / animation */
.steps {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.step {
  display: flex;
  flex-direction: column;
  flex: 1;
  transition: opacity var(--slide) var(--ease), transform var(--slide) var(--ease);
}

.step:not(.step-active) {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(28px);
}

.step.step-active {
  position: relative;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.step.step-exit-left {
  opacity: 0;
  transform: translateX(-28px);
}

.step.step-enter-from-right {
  opacity: 0;
  transform: translateX(28px);
}

.step.step-enter-from-left {
  opacity: 0;
  transform: translateX(-28px);
}

.field-block {
  flex: 1;
}

.field {
  position: relative;
  margin-top: 8px;
}

.field input {
  width: 100%;
  height: 56px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  outline: none;
  caret-color: var(--border-focus);
  transition: border-color 0.15s, padding 0.05s;
}

.field input:hover:not(:focus):not(.has-error) {
  border-color: var(--text);
}

.field input:focus {
  border-color: var(--border-focus);
  border-width: 2px;
  padding: 12px 14px;
}

.field input.has-error {
  border-color: var(--error);
  border-width: 2px;
  padding: 12px 14px;
}

.field label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 4px;
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  transition: top 0.15s var(--ease), font-size 0.15s var(--ease), color 0.15s;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 12px;
  color: var(--border-focus);
}

.field input.has-error + label,
.field input.has-error:focus + label {
  color: var(--error);
}

.field-error {
  display: none;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  color: var(--error);
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
}

.field-error.visible {
  display: flex;
  animation: errIn 180ms var(--ease);
}

.field-error svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 0;
}

@keyframes errIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.link {
  display: inline-block;
  margin-top: 14px;
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hint {
  margin: 32px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.hint a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

.hint a:hover {
  text-decoration: underline;
}

.show-pass {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  width: fit-content;
}

.show-pass input {
  width: 18px;
  height: 18px;
  accent-color: var(--btn);
  margin: 0;
  cursor: pointer;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 40px;
  gap: 8px;
}

.btn-text {
  border: none;
  background: transparent;
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: 0 12px;
  height: 40px;
  border-radius: 20px;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.btn-text:hover {
  background: var(--link-hover-bg);
}

.btn-primary {
  border: none;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: 0 24px;
  height: 40px;
  border-radius: 20px;
  cursor: pointer;
  min-width: 80px;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  background: var(--btn-hover);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.footer {
  width: 100%;
  max-width: 1080px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 8px 28px;
  font-size: 12px;
  color: var(--muted);
  position: relative;
  z-index: 5;
}

/* —— Google-style language picker —— */
.lang-picker {
  position: relative;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 4px 8px 8px;
  border-radius: 4px;
  line-height: 1.2;
}

.lang-trigger:hover {
  background: var(--hover-fill);
}

.lang-caret {
  opacity: 0.85;
}

.lang-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 4px);
  width: min(480px, calc(100vw - 24px));
  max-height: 420px;
  background: var(--menu-bg);
  border: 1px solid var(--menu-border);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483646;
}

.lang-menu[hidden] {
  display: none !important;
}

.lang-search {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--menu-border);
  color: var(--muted);
  flex: 0 0 auto;
  background: var(--menu-bg);
}

.lang-search svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}

.lang-search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  min-width: 0;
  padding: 0;
  caret-color: var(--link);
}

.lang-search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.lang-list {
  /* column-first: вниз, затем вторая колонка */
  display: block;
  column-count: 2;
  column-gap: 0;
  column-fill: auto;
  height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 8px;
  box-sizing: border-box;
  background: var(--menu-bg);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  padding: 8px 16px;
  cursor: pointer;
  line-height: 20px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}

.lang-option:hover {
  background: var(--hover-fill);
}

.lang-option .lang-check {
  width: 20px;
  height: 20px;
  min-width: 20px;
  flex-shrink: 0;
  color: var(--check);
  opacity: 0;
}

.lang-option.is-selected .lang-check {
  opacity: 1;
}

.lang-option .lang-name {
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.lang-empty {
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  column-span: all;
}

.footer-links {
  display: flex;
  gap: 4px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 12px;
}

.footer-links a:hover {
  background: var(--hover-fill);
}

@media (max-width: 720px) {
  #maket-exam-banner {
    flex-direction: column;
    gap: 2px;
    min-height: 52px;
    font-size: 14px;
  }

  body {
    padding-top: 52px;
    background: var(--card);
  }

  .wrap {
    padding: 8px 0 0;
    justify-content: flex-start;
  }

  .card {
    border: none;
    border-radius: 0;
    grid-template-columns: 1fr;
    padding: 24px 24px 16px;
    min-height: auto;
  }

  .col-left {
    padding-right: 0;
    margin-bottom: 28px;
  }

  .col-right {
    padding-left: 0;
  }

  .left-copy.is-hidden {
    right: 0;
  }

  h1 {
    font-size: 32px;
  }

  .hint {
    margin-top: 24px;
  }

  .actions {
    margin-top: 28px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px 24px 32px;
  }

  .lang-list {
    column-count: 1;
    height: auto;
    max-height: 280px;
  }

  .lang-menu {
    width: min(360px, calc(100vw - 24px));
  }

  .steps {
    min-height: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step,
  .left-copy,
  .field-error {
    transition: none !important;
    animation: none !important;
  }

  .auth-spinner {
    animation: none !important;
  }

  .auth-spinner-arc {
    stroke-dasharray: 80 126;
  }
}

/* —— Post-verify loading: dim screen + spinner only —— */
.auth-loading {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}

.auth-loading[hidden] {
  display: none !important;
}

.auth-spinner {
  width: 48px;
  height: 48px;
  animation: auth-spin 1.4s linear infinite;
}

.auth-spinner svg {
  display: block;
  width: 48px;
  height: 48px;
}

.auth-spinner-track {
  stroke: rgba(255, 255, 255, 0.22);
}

.auth-spinner-arc {
  stroke: #fff;
  stroke-dasharray: 90 126;
  stroke-dashoffset: 0;
  transform-origin: 24px 24px;
  animation: auth-dash 1.4s ease-in-out infinite;
}

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

@keyframes auth-dash {
  0% {
    stroke-dasharray: 20 126;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 90 126;
    stroke-dashoffset: -35;
  }
  100% {
    stroke-dasharray: 20 126;
    stroke-dashoffset: -125;
  }
}
