:root {
  --bg: #0b0d12;
  --bg-top: #202639;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --text: #161821;
  --muted: #555b6d;
  --line: #e9ebf2;
  --primary: #6558f5;
  --primary-dark: #5145d8;
  --primary-soft: #efedff;
  --success: #1d9b62;
  --danger: #d64b5d;
  --shadow: 0 24px 70px rgba(42, 45, 74, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, var(--bg-top) 0, var(--bg) 48%);
  background-attachment: fixed;
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.auth-page {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.auth-page::before,
.auth-page::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.auth-page::before {
  width: 250px;
  height: 250px;
  top: -110px;
  right: -80px;
  background: rgba(101, 88, 245, 0.08);
}

.auth-page::after {
  width: 220px;
  height: 220px;
  bottom: -100px;
  left: -70px;
  background: rgba(73, 190, 164, 0.08);
}

.auth-container {
  width: min(100%, 460px);
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  user-select: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -1px;
  background: linear-gradient(145deg, #7267ff, #5548d8);
  box-shadow: 0 10px 24px rgba(101, 88, 245, 0.28);
}

.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.auth-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 34px;
}

.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.card-title {
  margin: 0 0 9px;
  font-size: clamp(24px, 6vw, 31px);
  line-height: 1.35;
  letter-spacing: -0.7px;
  font-weight: 800;
}

.card-subtitle {
  margin: 0 auto;
  max-width: 340px;
  color: #555b6d;
  font-size: 14px;
  line-height: 1.9;
}

.google-button,
.primary-button,
.secondary-button {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.google-button {
  background: #fff;
  border: 1px solid var(--line);
  color: #262834;
  box-shadow: 0 7px 20px rgba(30, 34, 60, 0.06);
}

.google-button:hover {
  transform: translateY(-1px);
  border-color: #dcdeea;
  box-shadow: 0 11px 28px rgba(30, 34, 60, 0.09);
}

.google-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
}

.primary-button {
  background: linear-gradient(135deg, #6d60f8, var(--primary));
  color: #fff;
  box-shadow: 0 13px 25px rgba(101, 88, 245, 0.25);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(101, 88, 245, 0.31);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: #363947;
}

.secondary-button:hover {
  background: #fafaff;
  border-color: #dedfed;
}

.security-note {
  margin: 18px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #9295a5;
  font-size: 12px;
  line-height: 1.8;
}

.security-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4fb98c;
  box-shadow: 0 0 0 4px rgba(79, 185, 140, 0.12);
}

.form-section {
  margin-top: 24px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.section-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.section-hint,
.input-counter {
  color: #999cad;
  font-size: 12px;
}

.field {
  position: relative;
}

.text-input {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  outline: none;
  padding: 0 15px;
  font-size: 14px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.text-input::placeholder {
  color: #aaaebe;
}

.text-input:focus {
  background: #fff;
  border-color: rgba(101, 88, 245, 0.55);
  box-shadow: 0 0 0 4px rgba(101, 88, 245, 0.09);
}

.avatar-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f5f6fa;
}

.avatar-tab {
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.avatar-tab:hover {
  color: var(--text);
}

.avatar-tab.is-active,
.avatar-tab[aria-selected="true"] {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 3px 10px rgba(44, 47, 80, 0.08);
}

.avatar-tab:focus-visible,
.avatar-btn:focus-visible {
  outline: 3px solid rgba(101, 88, 245, 0.2);
  outline-offset: 2px;
}

.avatar-group-panel[hidden] {
  display: none;
}

.avatar-group-panel {
  max-height: min(360px, 42vh);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 2px 6px 6px 2px;
}

.avatar-group-panel::-webkit-scrollbar {
  width: 8px;
}

.avatar-group-panel::-webkit-scrollbar-track {
  background: transparent;
}

.avatar-group-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(101, 88, 245, 0.24);
  background-clip: padding-box;
}

.avatar-group-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(101, 88, 245, 0.38);
  background-clip: padding-box;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.avatar-btn {
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 30px;
  position: relative;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.avatar-btn--image {
  overflow: hidden;
  padding: 0;
  background: #eef0f7;
}

.avatar-btn--image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

.avatar-btn:hover {
  transform: translateY(-2px);
  border-color: #d8d8e8;
}

.avatar-btn.selected,
.avatar-btn[aria-pressed="true"] {
  background: var(--primary-soft);
  border-color: rgba(101, 88, 245, 0.55);
  box-shadow: inset 0 0 0 1px rgba(101, 88, 245, 0.12), 0 8px 18px rgba(101, 88, 245, 0.10);
}

.avatar-btn.selected::after,
.avatar-btn[aria-pressed="true"]::after {
  content: "✓";
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  position: absolute;
  inset-block-start: 6px;
  inset-inline-start: 6px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.form-actions {
  margin-top: 28px;
}

.form-message {
  min-height: 24px;
  margin: 12px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

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

.profile-avatar {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 30px;
  background: linear-gradient(145deg, #f0efff, #fff);
  border: 1px solid #e4e2ff;
  box-shadow: 0 16px 34px rgba(101, 88, 245, 0.15);
  font-size: 56px;
  object-fit: cover;
}

.profile-name {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

.profile-username {
  margin: 4px 0 0;
  direction: ltr;
  color: var(--muted);
  font-size: 14px;
}

.profile-meta {
  margin: 24px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(250, 250, 253, 0.76);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.profile-meta-item {
  min-width: 0;
  flex: 1;
}

.profile-meta-label {
  display: block;
  color: #9b9ead;
  font-size: 11px;
  margin-bottom: 5px;
}

.profile-meta-value {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  overflow: hidden;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 11px;
  border-radius: 999px;
  color: #5e50dc;
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.helper-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fafafe;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

.footer-note {
  margin: 18px 0 0;
  text-align: center;
  color: #a3a6b4;
  font-size: 11px;
  line-height: 1.8;
}

@media (max-width: 560px) {
  .auth-page {
    align-items: start;
    padding: 22px 14px;
  }

  .auth-container {
    margin-top: min(8vh, 48px);
  }

  .auth-card {
    padding: 26px 20px;
    border-radius: 24px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .card-header {
    margin-bottom: 23px;
  }

  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .avatar-group-panel {
    max-height: min(300px, 38vh);
    padding-inline-end: 4px;
  }

  .avatar-btn {
    border-radius: 15px;
    font-size: 26px;
  }

  .profile-avatar {
    width: 96px;
    height: 96px;
    font-size: 48px;
    border-radius: 26px;
  }
}

@media (max-width: 380px) {
  .auth-page {
    padding-inline: 10px;
  }

  .auth-card {
    padding-inline: 16px;
  }

  .avatar-btn {
    font-size: 23px;
  }

  .profile-meta {
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.alert-error {
  color: var(--danger);
  background: rgba(214, 75, 93, 0.08);
  border: 1px solid rgba(214, 75, 93, 0.16);
}

.profile-actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.logout-form {
  margin: 2px 0 0;
  text-align: center;
}

.text-button {
  padding: 8px 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  transition: color 160ms ease;
}

.text-button:hover {
  color: var(--danger);
}


/* Joymap unified service background */
.auth-page::before,
.auth-page::after {
  display: none;
}

.auth-card,
.profile-card,
.complete-profile-card {
  box-shadow:
    0 24px 70px
    rgba(0, 0, 0, 0.26);
}


/* =========================
   Locale / direction
   ========================= */

html[dir="rtl"] {
  direction: rtl;
}

html[dir="ltr"] {
  direction: ltr;
}

html[lang="fa"] body,
html[lang="ar"] body {
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
}

html[lang="en"] body,
html[lang="tr"] body {
  font-family: Inter, "Segoe UI", Tahoma, Arial, sans-serif;
}

.locale-switcher {
  position: fixed;
  z-index: 1000;
  inset-block-start: 14px;
  inset-inline-end: 14px;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  min-height: 38px;
  padding: 5px 8px;

  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;

  background: rgba(14, 17, 24, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.locale-switcher-icon {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1;
}

.locale-switcher select {
  width: auto;
  min-width: 72px;
  padding: 4px 24px 4px 4px;

  border: 0;
  outline: none;

  background: transparent;
  color: #ffffff;

  font: inherit;
  font-size: 12px;
  font-weight: 700;

  cursor: pointer;
}

html[dir="rtl"] .locale-switcher select {
  padding: 4px 4px 4px 24px;
}

.locale-switcher option {
  color: #111827;
  background: #ffffff;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html[dir="ltr"] .card-header,
html[dir="ltr"] .helper-box,
html[dir="ltr"] .section-label-row,
html[dir="ltr"] .profile-meta {
  text-align: left;
}

html[dir="rtl"] .card-header,
html[dir="rtl"] .helper-box,
html[dir="rtl"] .section-label-row,
html[dir="rtl"] .profile-meta {
  text-align: right;
}

@media (max-width: 560px) {
  .locale-switcher {
    inset-block-start: 10px;
    inset-inline-end: 10px;
    min-height: 34px;
    padding: 4px 7px;
  }

  .locale-switcher select {
    min-width: 66px;
    font-size: 11px;
  }
}


/* Stage 3 auth locale polish */

.text-input[dir="auto"] {
  unicode-bidi: plaintext;
  text-align: start;
}

.input-counter,
.profile-username,
.error-page-code {
  unicode-bidi: isolate;
}

.error-page-card {
  text-align: center;
}

.error-page-code {
  margin-bottom: 10px;
  color: var(--primary);
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  direction: ltr;
}

.error-page-action {
  margin-top: 26px;
}


/* CSP-safe locale switcher hotfix */

form.locale-switcher {
  margin: 0;
}

.locale-switcher-submit {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
}


/* Profile-local language control */
.auth-card-locale-row {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 20px;
}

html[dir="rtl"] .auth-card-locale-row {
  justify-content: flex-start;
}

.auth-card-locale-row .locale-switcher {
  position: static;
  inset: auto;
  z-index: auto;
  min-height: 36px;
  padding: 4px 7px;
  border-color: var(--line);
  background: #fafafe;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.auth-card-locale-row .locale-switcher select {
  color: #111827;
}

@media (max-width: 560px) {
  .auth-card-locale-row {
    margin-bottom: 16px;
  }
}


/* Central Joymap provider chooser */
.auth-login-choice {
  max-width: 440px;
}

.auth-provider-list {
  display: grid;
  gap: 10px;
}

.provider-button {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid #d7dce3;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.provider-button:hover:not(:disabled) {
  border-color: #aeb6c2;
  background: #f8fafc;
}

.provider-button:disabled {
  opacity: .56;
  cursor: default;
}

.provider-button small {
  color: #8a94a3;
  font-size: 10px;
  font-weight: 600;
}

.provider-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.provider-mark-facebook {
  background: #1877f2;
}

.auth-provider-note {
  margin: 14px 0 0;
  color: #7a8492;
  font-size: 11px;
  line-height: 1.8;
  text-align: center;
}

/* =========================================================
   Auth profile hub + provider icon consistency
   ========================================================= */

.provider-mark-apple {
  background: #111827;
}

.apple-icon {
  width: 18px;
  height: 18px;
  display: block;
  color: #ffffff;
}

.profile-services {
  margin-top: 22px;
  text-align: start;
}

.profile-services-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  align-items: end;
  gap: 14px;
  margin-bottom: 12px;
}

.profile-services-kicker {
  display: block;
  margin-bottom: 4px;
  color: #6558e8;
  font-size: 10px;
  font-weight: 800;
}

.profile-services-heading h2 {
  margin: 0;
  color: #111827;
  font-size: 17px;
  line-height: 1.5;
}

.profile-services-heading--simple {
  grid-template-columns: 1fr;
  align-items: center;
}

.profile-services-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.75;
}

.profile-service-grid {
  display: grid;
  gap: 10px;
}

.profile-service-card {
  min-width: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid #dfe3e8;
  border-radius: 14px;
  background: #fff;
  color: #111827;
  text-decoration: none;
}

.profile-service-card.is-active {
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.profile-service-card.is-active:hover {
  transform: translateY(-1px);
  border-color: #b9b3ff;
  box-shadow: 0 8px 22px rgba(101, 88, 245, .10);
}

.profile-service-card.is-disabled {
  background: #f8f9fb;
  color: #7b8491;
  opacity: .72;
}

.profile-service-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #f0efff;
  color: #5f52df;
}

.profile-service-card.is-disabled .profile-service-icon {
  background: #eef0f3;
  color: #7e8793;
}

.profile-service-icon svg {
  width: 23px;
  height: 23px;
  display: block;
}

.profile-service-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-service-copy strong {
  font-size: 13px;
  font-weight: 800;
}

.profile-service-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
  text-overflow: ellipsis;
}

.profile-service-state {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #eceef2;
  color: #737c88;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.profile-service-state.is-active {
  background: #ecfdf5;
  color: #047857;
}

@media (max-width: 560px) {
  .profile-services-heading {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .profile-service-card {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    min-height: 68px;
    padding: 10px;
  }

  .profile-service-icon {
    width: 40px;
    height: 40px;
  }

  .profile-service-copy strong {
    font-size: 12px;
  }

  .profile-service-copy small {
    font-size: 9px;
  }
}
