:root {
  --color-telegram-blue: #c92d88;
  --color-telegram-blue-hover: #a72465;
  --text: #000000;
  --hint: #707579;
  --err: #e53935;
  --field-border: #dfe1e5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: "Roboto", -apple-system, "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#auth-qr-form {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.view { display: block; }
.hidden { display: none !important; }

h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 24px 0 0;
  letter-spacing: -0.2px;
}

.subtitle {
  font-size: 14px;
  color: var(--hint);
  line-height: 1.5;
  margin: 14px 0 26px;
  padding: 0 8px;
}

/* ===================== QR (реальные правила Telegram) ===================== */
.qr-outer {
  width: 280px;
  height: 280px;
  position: relative;
  margin: 0 auto;
}
.qr-inner {
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 280px;
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
}
.qr-inner.open {
  animation: 0.4s ease-in-out forwards qr-show;
}
@keyframes qr-show {
  0%   { opacity: 0; transform: scale(0.7); }
  50%  { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
.qr-container {
  background-color: #fff;
  border-radius: 1.5rem;
  overflow: hidden;
}
.qr-container svg { display: block; }

/* синий круг с анимированным самолётиком — поверх центра QR */
.qr-plane {
  z-index: 1;
  width: 54px;
  height: 54px;
  background-color: var(--color-telegram-blue);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-plane svg { width: 100%; height: 100%; }

.qr-loading {
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 280px;
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid #e6e6e6;
  border-top-color: var(--color-telegram-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* список шагов */
#auth-qr-form ol {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 22px auto 28px;
  max-width: 300px;
  text-align: left;
}
#auth-qr-form ol li {
  counter-increment: step;
  position: relative;
  padding-left: 36px;
  font-size: 14px;
  line-height: 1.45;
  color: #222;
  margin-bottom: 16px;
}
#auth-qr-form ol li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--color-telegram-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
#auth-qr-form ol b { font-weight: 500; }

/* логотип на экранах телефона/2FA */
.auth-logo { width: 120px; height: 120px; margin: 0 auto; }
.auth-logo svg { width: 100%; height: 100%; }

/* ===================== поля ввода ===================== */
.field { position: relative; margin: 0 0 18px; }
.field input {
  width: 100%;
  padding: 15px 14px;
  font-size: 16px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.field input:focus { border-color: var(--color-telegram-blue); border-width: 2px; padding: 14px 13px; }
.field label {
  position: absolute;
  left: 12px;
  top: 15px;
  font-size: 16px;
  color: var(--hint);
  background: #fff;
  padding: 0 5px;
  pointer-events: none;
  transition: all .15s ease;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  top: -8px;
  font-size: 12px;
  color: var(--color-telegram-blue);
}
.field input:not(:focus):not(:placeholder-shown) + label { color: var(--hint); }

/* ===================== выбор страны ===================== */
.country-field { position: relative; }
.country-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 14px;
  font-size: 16px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.country-btn .flag { width: 24px; height: 18px; border-radius: 3px; object-fit: cover; flex: 0 0 auto; }
.country-btn #country-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-btn .chevron { width: 20px; height: 20px; color: var(--hint); flex: 0 0 auto; transition: transform .15s; }
.country-field.open .country-btn { border-color: var(--color-telegram-blue); border-width: 2px; padding: 14px 13px; }
.country-field.open .country-btn .chevron { transform: rotate(180deg); }

.country-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  overflow: hidden;
}
.country-search {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border: none;
  border-bottom: 1px solid var(--field-border);
  outline: none;
  background: #fff;
  color: var(--text);
}
.country-options {
  max-height: 260px;
  overflow-y: auto;
  /* тонкий прозрачный скроллбар, как custom-scroll в Telegram */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color .3s;
}
.country-options:hover { scrollbar-color: rgba(120,130,140,.5) transparent; }
.country-options::-webkit-scrollbar { width: 6px; }
.country-options::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 6px;
}
.country-options:hover::-webkit-scrollbar-thumb { background-color: rgba(120,130,140,.5); }
.country-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 15px;
}
.country-option:hover, .country-option.active { background: rgba(51,144,236,.1); }
.country-option .flag { width: 24px; height: 18px; border-radius: 3px; object-fit: cover; flex: 0 0 auto; }
.country-option .c-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-option .c-dial { color: var(--hint); font-size: 14px; }

/* ===================== кнопки ===================== */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--color-telegram-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--color-telegram-blue-hover); }

.btn-link {
  margin-top: 22px;
  border: none;
  background: none;
  color: var(--color-telegram-blue);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .4px;
  cursor: pointer;
  font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ===================== успех ===================== */
.success-check {
  width: 96px; height: 96px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--color-telegram-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop .3s ease;
}
.success-check svg { width: 52px; height: 52px; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.msg { margin-top: 16px; font-size: 14px; min-height: 20px; }
.msg.error { color: var(--err); }
.msg.ok { color: #4caf50; }

/* ===================== тёмная тема ===================== */
@media (prefers-color-scheme: dark) {
  body { background: #17212b; color: #fff; }
  h1 { color: #fff; }
  #auth-qr-form ol li { color: #e6ecf2; }
  .field input { background: #17212b; color: #fff; border-color: #2b3a4a; }
  .field label { background: #17212b; }
  .country-btn { background: #17212b; color: #fff; border-color: #2b3a4a; }
  .country-list, .country-search { background: #232e3c; color: #fff; border-color: #2b3a4a; }
  .country-search { border-bottom-color: #2b3a4a; }
  .country-option:hover, .country-option.active { background: rgba(51,144,236,.2); }
  /* QR всегда на белом фоне qr-container, как в Telegram */
}
