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

:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --bg-hover: #f8f9fa;
  --bg-fb-tablet: #f5f5f5;
  --text-primary: #0a1317;
  --text-secondary: #5d6c75;
  --text-muted: #657786;
  --border-subtle: #dde2e5;
  --border-divider: #efefef;
  --border-input: #dbdbdb;
  --border-input-focus: #737373;
  --border-create: #b7d4fb;
  --blue-primary: #0052cc;
  --blue-primary-hover: #0041a8;
  --blue-disabled: #9dbbf2;
  --meta-color: #1c2b33;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #000000;
    --bg-surface: #121212;
    --bg-hover: #1a1a1a;
    --bg-fb-tablet: #1a1a1a;
    --text-primary: #f5f5f5;
    --text-secondary: #a8a8a8;
    --text-muted: #a8a8a8;
    --border-subtle: #262626;
    --border-divider: #1f1f1f;
    --border-input: #363636;
    --border-input-focus: #a8a8a8;
    --border-create: #2b4c7e;
    --blue-primary: #0064e0;
    --blue-primary-hover: #0052cc;
    --blue-disabled: #1b3b5c;
    --meta-color: #f5f5f5;
  }
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.page-wrapper {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.top-brand {
  position: absolute;
  top: 28px;
  left: 36px;
  z-index: 20;
}

html[dir="rtl"] .top-brand {
  left: auto;
  right: 36px;
}

.ig-brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-icon-svg {
  width: 36px;
  height: 36px;
}

/* ==========================================================================
   MOBILE VIEWPORT BASE (<= 640px) — 1:1 with reference screenshots:
   - Meta sits right below "Create new account" (not pushed to the very bottom)
   - Deep royal blue Log in button
   ========================================================================== */
.top-brand,
.left-pane,
.site-footer,
.btn-facebook {
  display: none;
}

.split-layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 100vh;
  min-height: 100dvh;
}

.right-pane {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px calc(24px + env(safe-area-inset-bottom, 0px));
  width: 100%;
}

.mobile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.mobile-lang-top {
  margin-bottom: 24px;
}

.mobile-lang-top .native-lang-picker {
  font-size: 13px;
  color: var(--text-secondary);
}

.mobile-logo-center {
  margin-bottom: 28px;
}

.auth-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 400px;
}

.auth-top-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.form-heading {
  display: none;
}

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

.floating-field {
  position: relative;
  width: 100%;
}

.floating-field input {
  width: 100%;
  height: 58px;
  padding: 22px 42px 8px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-input);
  border-radius: 15px;
  outline: none;
}

html[dir="rtl"] .floating-field input {
  padding: 22px 16px 8px 42px;
}

.floating-field input:focus {
  border-color: var(--border-input-focus);
}

.floating-field label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-secondary);
  pointer-events: none;
  transition: all 0.14s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 48px);
}

html[dir="rtl"] .floating-field label {
  left: auto;
  right: 16px;
}

.floating-field input:focus + label,
.floating-field input:not(:placeholder-shown) + label {
  top: 15px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.field-action-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html[dir="rtl"] .field-action-btn {
  right: auto;
  left: 12px;
}

.field-action-btn.hidden {
  display: none;
}

.btn-primary {
  width: 100%;
  height: 45px;
  margin-top: 4px;
  border: none;
  border-radius: 999px;
  background-color: var(--blue-disabled);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: not-allowed;
}

.btn-primary:not(:disabled) {
  background-color: var(--blue-primary);
  cursor: pointer;
}

.btn-primary:not(:disabled):hover {
  background-color: var(--blue-primary-hover);
}

.forgot-link {
  align-self: center;
  margin-top: 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
}

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

/* Grouped directly with "Create new account" like reference */
.secondary-actions {
  margin-top: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.secondary-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.btn-create-account {
  width: 100%;
  height: 45px;
  border-radius: 999px;
  border: 1px solid var(--border-create);
  background-color: var(--bg-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--blue-primary);
  text-decoration: none;
}

.btn-create-account:hover {
  background-color: var(--bg-hover);
}

.meta-wordmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--meta-color);
}

.meta-infinity-svg {
  width: 22px;
  height: 15px;
  color: #0064e0;
}

.native-lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
}

.lang-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-primary);
  background-color: var(--bg-surface);
}

/* ==========================================================================
   TABLET / PORTRAIT DESKTOP VIEWPORT (min-width: 641px and max-width: 1023px)
   ========================================================================== */
@media (min-width: 641px) and (max-width: 1023px) {
  .mobile-header {
    display: none;
  }

  .btn-facebook {
    display: inline-flex;
  }

  .top-brand {
    position: static;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 0 22px;
    border-bottom: 1px solid var(--border-divider);
  }

  .brand-icon-svg {
    width: 24px;
    height: 24px;
  }

  .split-layout {
    display: grid;
    grid-template-columns: 1fr;
    min-height: calc(100vh - 68px);
    min-height: calc(100dvh - 68px);
  }

  .right-pane {
    justify-content: center;
    padding: 36px 24px 64px;
  }

  .auth-container {
    max-width: 300px;
  }

  .form-heading {
    display: block;
    font-size: 14px;
    margin-bottom: 10px;
  }

  .auth-form {
    gap: 7px;
  }

  .floating-field input {
    height: 38px;
    padding: 15px 11px 4px;
    font-size: 12px;
    border-radius: 5px;
  }

  .floating-field label {
    left: 10px;
    font-size: 11px;
  }

  html[dir="rtl"] .floating-field label {
    left: auto;
    right: 10px;
  }

  .floating-field input:focus + label,
  .floating-field input:not(:placeholder-shown) + label {
    top: 8px;
    font-size: 9px;
  }

  .btn-primary {
    height: 32px;
    border-radius: 6px;
    font-size: 12.5px;
    margin-top: 2px;
  }

  .forgot-link {
    margin-top: 10px;
    font-size: 11px;
  }

  .secondary-actions {
    margin-top: 28px;
    gap: 8px;
  }

  .secondary-buttons {
    gap: 8px;
  }

  .btn-facebook,
  .btn-create-account {
    width: 100%;
    height: 30px;
    font-size: 11.5px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    text-decoration: none;
  }

  .btn-facebook {
    color: var(--text-primary);
    background-color: var(--bg-fb-tablet);
    border-color: transparent;
  }

  .btn-create-account {
    color: var(--blue-primary);
    border-color: var(--border-create);
  }

  .btn-facebook svg {
    width: 14px;
    height: 14px;
  }

  .meta-wordmark {
    margin-top: 10px;
    font-size: 11.5px;
    gap: 4px;
  }

  .meta-infinity-svg {
    width: 16px;
    height: 11px;
    color: currentColor;
  }

  .site-footer {
    display: block;
    border-top: 1px solid var(--border-divider);
    padding: 20px 24px 28px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
  }

  .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
    margin-bottom: 12px;
  }

  .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
  }

  .footer-links a:hover {
    text-decoration: underline;
  }

  .footer-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
  }
}

/* ==========================================================================
   FULL PC DESKTOP VIEWPORT (min-width: 1024px)
   ========================================================================== */
@media (min-width: 1024px) {
  .mobile-header {
    display: none;
  }

  .left-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 40px 24px;
    border-right: 1px solid var(--border-divider);
  }

  html[dir="rtl"] .left-pane {
    border-right: none;
    border-left: 1px solid var(--border-divider);
  }

  .btn-facebook {
    display: inline-flex;
  }

  .top-brand {
    display: block;
    position: absolute;
    top: 28px;
    left: 36px;
    z-index: 20;
  }

  html[dir="rtl"] .top-brand {
    left: auto;
    right: 36px;
  }

  .brand-icon-svg {
    width: 36px;
    height: 36px;
  }

  .split-layout {
    display: grid;
    grid-template-columns: 1.32fr 1fr;
    min-height: calc(100vh - 88px);
  }

  .showcase-content {
    max-width: 520px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .headline {
    font-size: clamp(28px, 2.7vw, 38px);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 28px;
  }

  .gradient-friends {
    background: linear-gradient(90deg, #ff6b00 0%, #ff0069 52%, #d300c5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 400;
  }

  .showcase-media {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .stories-hero-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
  }

  .right-pane {
    justify-content: center;
    padding: 40px 32px;
  }

  .auth-container {
    max-width: 410px;
  }

  .form-heading {
    display: block;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    margin: 0 0 12px;
  }

  .auth-form {
    gap: 8px;
  }

  .floating-field input {
    height: 38px;
    padding: 16px 36px 4px 10px;
    font-size: 13px;
    border-radius: 6px;
  }

  html[dir="rtl"] .floating-field input {
    padding: 16px 10px 4px 36px;
  }

  .floating-field label {
    left: 10px;
    font-size: 12px;
  }

  html[dir="rtl"] .floating-field label {
    left: auto;
    right: 10px;
  }

  .floating-field input:focus + label,
  .floating-field input:not(:placeholder-shown) + label {
    top: 9px;
    font-size: 9.5px;
  }

  .btn-primary {
    height: 34px;
    border-radius: 8px;
    font-size: 14px;
    margin-top: 4px;
  }

  .forgot-link {
    margin-top: 12px;
    font-size: 12px;
  }

  .secondary-actions {
    margin-top: 28px;
    gap: 8px;
  }

  .secondary-buttons {
    gap: 8px;
  }

  .btn-facebook,
  .btn-create-account {
    width: 100%;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
  }

  .btn-facebook {
    color: var(--text-primary);
  }

  .btn-facebook:hover {
    background-color: var(--bg-hover);
  }

  .btn-create-account {
    color: var(--blue-primary);
    border-color: var(--border-create);
  }

  .btn-create-account:hover {
    background-color: var(--bg-hover);
  }

  .meta-wordmark {
    margin-top: 12px;
    font-size: 13px;
    gap: 5px;
  }

  .meta-infinity-svg {
    width: 18px;
    height: 12px;
    color: currentColor;
  }

  .site-footer {
    display: block;
    border-top: 1px solid var(--border-divider);
    padding: 20px 24px 28px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
  }

  .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
    margin-bottom: 12px;
  }

  .footer-links a {
    color: var(--text-muted);
    text-decoration: none;
  }

  .footer-links a:hover {
    text-decoration: underline;
  }

  .footer-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
  }
}
