:root {
  --capture-dim: 0.22;
  --capture-saturation: 0.78;
  --brand: #7acc35;
  --brand-hover: #8ad946;
  --brand-active: #71bd2f;
  --text: #26282c;
  --modal-overlay: rgb(38 40 44 / 0.45);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #efffee; }
body {
  margin: 0;
  min-height: 100svh;
  isolation: isolate;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
[hidden] { display: none !important; }

/* Original KOOK login layers and geometry; the foreground card is separate. */
.login-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.login-scene { position: absolute; inset: 0; filter: saturate(var(--capture-saturation)); }
.login-back-left, .login-back-right { position: absolute; top: 0; width: 50%; height: 100%; }
.login-back-left { left: 0; background: linear-gradient(#f9ffb9, #a2ff9f); }
.login-back-right { right: 0; background: #efffee; }
.login-back-img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  max-width: 1920px;
  height: 100%;
  transform: translate(-50%, -50%);
}
.login-artwork { position: absolute; inset: 0 50% 0 0; display: flex; align-items: center; justify-content: center; }
.login-artwork img { display: block; width: 36.458vw; min-width: 400px; max-width: 700px; height: auto; }
.login-logo { position: absolute; top: 40px; left: 40px; width: 109px; height: 46px; }
.capture-wash { position: absolute; inset: 0; background: rgb(0 0 0 / var(--capture-dim)); }

.invite-layout {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50%;
  min-height: 100svh;
  margin-left: 50%;
  padding: 40px 24px;
}
.friend-card {
  width: 440px;
  max-width: 100%;
  padding: 36px 32px 24px;
  border: 1px solid rgb(255 255 255 / 0.8);
  border-radius: 16px;
  background: #fff;
  text-align: center;
  box-shadow: 0 14px 48px rgb(33 48 27 / 0.10), 0 2px 8px rgb(33 48 27 / 0.04);
}
h1 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.25; letter-spacing: -0.7px; overflow-wrap: anywhere; }
.description { margin: 12px 0 0; color: #767b82; font-size: 14px; line-height: 1.6; }
.profile { margin: 30px 0; }
.avatar {
  position: relative;
  width: 96px;
  height: 96px;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 50%;
  background: #eef6e6;
  box-shadow: 0 0 0 5px #f5f8f1;
}
.avatar-fallback { display: grid; place-items: center; height: 100%; color: #527634; font-size: 30px; font-weight: 600; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.username { margin: 18px 0 0; overflow-wrap: anywhere; font-size: 22px; font-weight: 650; line-height: 1.4; }
.user-tag { margin-left: 2px; color: #92969d; font-size: 18px; font-weight: 400; }
.card-actions { padding-top: 24px; border-top: 1px solid #eef0ed; }
.add-friend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  color: #183505;
  background: var(--brand);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}
.add-friend:hover { background: var(--brand-hover); }
.add-friend:active { background: var(--brand-active); transform: translateY(1px); }
.add-friend:disabled { opacity: 0.65; cursor: default; transform: none; }
:is(button, a):focus-visible { outline: 3px solid #395f1f; outline-offset: 4px; }
.request-status { margin: 14px 0 0; color: #777d85; font-size: 13px; line-height: 1.5; }

/* Всплывающее окно: фон страницы становится серым, само окно — белое с зелёным акцентом. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-overlay);
  animation: modal-fade 160ms ease;
}
.modal-surface {
  position: relative;
  display: flex;
  flex-direction: column;
  /* 80% минус 50% — окно-колонка по центру экрана. */
  width: 40%;
  max-width: 1100px;
  max-height: calc(100svh - 40px);
  padding: 24px 0 0;
  border: 1px solid rgb(255 255 255 / 0.8);
  border-top: 3px solid var(--brand);
  border-radius: 16px;
  background: #fff;
  overflow-wrap: anywhere;
  box-shadow: 0 18px 56px rgb(20 28 15 / 0.28), 0 2px 8px rgb(33 48 27 / 0.08);
  animation: modal-pop 160ms ease;
}
.modal-surface:focus { outline: none; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #767b82;
  background: transparent;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease;
}
.modal-close:hover { color: #3f6b1d; background: #f1f8ea; }
.modal-close:active { background: #e6f3d8; }
.modal-title { flex: none; margin: 0; padding: 0 56px 0 24px; font-size: 20px; font-weight: 700; line-height: 1.3; letter-spacing: -0.3px; white-space: pre-line; }
/* Тело окна: пошаговая инструкция. Прокручивается только оно, заголовок остаётся на месте. */
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 16px;
  padding: 0 24px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.modal-body > :first-child { margin-top: 0; }
.modal-body > :last-child { margin-bottom: 0; }
.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.step { display: flex; gap: 12px; align-items: start; }
.step-number {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  color: #183505;
  background: var(--brand);
  font-size: 13px;
  font-weight: 700;
}
.step-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 18px;
  align-content: start;
  min-width: 0;
  flex: 1;
}
.step-text { min-height: 2.9em; overflow-wrap: anywhere; }
/* Текст шага читается как основной: тёмный, чуть крупнее и плотнее серой подписи. */
/* pre-line: переносы «\n» из настроек видны, а лишние пробелы по-прежнему схлопываются. */
.step-text { margin: 2px 0 0; color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.5; white-space: pre-line; }
/* Портретный снимок: он слева и растянут по высоте шага, текст справа от него. */
.step-content--media-right > .step-media {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  max-width: min(100%, 340px);
}
.step-content--media-right > .step-text { grid-column: 2; }
/* Широкий снимок: текст над ним, снимок занимает всю ширину шага. */
.step-content--wide > .step-text { grid-column: 1 / -1; }
.step-content--wide > .step-media {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  margin-top: 12px;
}
.step-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}
/* Портрет упирается в потолок по высоте, широкий — по ширине окна. */
.step-content--media-right .step-image { max-height: 340px; }
/* Снимок без файла — рамка под будущую картинку, той же ширины и пропорций. */
.step-media > .ph-image { width: 100%; margin-top: 0; }
/* Пустая рамка под будущие картинки и сама картинка из config/invite.js.
   Картинка занимает всю ширину шага и показывается целиком, без обрезки. */
.ph-image {
  margin-top: 10px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background:
    repeating-linear-gradient(45deg, #f6fbf1 0 10px, #fbfdf8 10px 20px);
}
.ph-image:not(img) { border: 1px dashed #cfe3bd; }
img.ph-image {
  display: block;
  width: 100%;
  height: auto;
}
.modal-note { margin: 18px 0 0; font-size: 14px; line-height: 1.5; text-align: center; white-space: pre-line; }
/* Вступительный текст перед первым шагом. */
.modal-intro { margin: 0 0 20px; color: var(--text); font-size: 14px; line-height: 1.55; white-space: pre-line; }
/* Нижняя панель окна: кнопка прижата к правому краю. */
.modal-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #eef0ed;
}
/* Сообщение о результате принятия: слева от кнопки, кнопка не сдвигается. */
.modal-status {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: #b3261e;
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}
.modal-done {
  min-width: 132px;
  min-height: 40px;
  padding: 8px 20px;
  border: 0;
  border-radius: 8px;
  color: #183505;
  background: var(--brand);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}
.modal-done:hover { background: var(--brand-hover); }
.modal-done:active { background: var(--brand-active); transform: translateY(1px); }
.modal-done:disabled { opacity: 0.65; cursor: default; transform: none; }
body.modal-open { overflow: hidden; }

@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

@media (max-width: 800px) {
  .desktop-break { display: none; }
  .login-logo { top: 24px; left: 24px; width: 95px; height: auto; }
  .login-artwork { right: 0; align-items: end; }
  .login-artwork img { width: 560px; min-width: 0; max-width: 110vw; opacity: 0.55; }
  .invite-layout { width: 100%; margin-left: 0; padding: 110px 20px 40px; }
  .modal { padding: 16px; }
  .modal-surface { width: 100%; max-height: calc(100svh - 32px); padding-top: 20px; }
  .modal-title { padding: 0 52px 0 20px; font-size: 18px; }
  .modal-body { padding: 0 20px 20px; }
  .modal-footer { flex-wrap: wrap; padding: 12px 20px; }
  /* Узко: сообщение занимает свою строку, кнопка — следующую во всю ширину. */
  .modal-status { flex: 1 1 100%; }
  .modal-done { min-width: 0; flex: 1; }
}
@media (max-width: 380px) {
  .invite-layout { padding-inline: 16px; }
  .friend-card { padding-inline: 22px; }
  h1 { font-size: 25px; }
  .desktop-break { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .add-friend { transition: none; }
  .modal-backdrop, .modal-surface { animation: none; }
}
