:root {
  --bg: #f6f8fc;
  --card: #ffffff;
  --soft-blue: #eaf3ff;
  --text: #111a2e;
  --muted: #717b8d;
  --line: #e5eaf3;
  --blue: #2f74f6;
  --blue-dark: #145ee5;
  --purple: #8c4cf7;
  --green: #23b777;
  --amber: #eca20f;
  --rose: #f05f78;
  --shadow: 0 18px 44px rgba(34, 66, 115, 0.09);
  --radius: 8px;
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #eef2f8;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 116, 246, 0.1), transparent 23rem),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

body,
button,
input,
select,
textarea {
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
}

button {
  cursor: pointer;
}

.phone-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 18px 106px;
  position: relative;
  overflow-x: hidden;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  direction: ltr;
  color: #05070c;
  font-weight: 900;
  letter-spacing: 0;
}

.status-icons {
  font-size: 0.86rem;
  white-space: nowrap;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 20px;
  direction: ltr;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #062455;
  text-decoration: none;
  font-size: 1.45rem;
  font-weight: 950;
  direction: ltr;
}

.brand-initial {
  color: #2473ef;
  font-size: 1.16em;
  text-shadow: 0 3px 8px rgba(36, 115, 239, 0.18);
}

.logo-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
}

.logo-mark svg {
  width: 100%;
  height: 100%;
}

.logo-mark path {
  fill: none;
  stroke: url("#logoGradient");
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-mark svg::before {
  content: "";
}

.logo-mark path:nth-child(1) {
  stroke: #31c5f4;
}

.logo-mark path:nth-child(2) {
  stroke: #2f74f6;
}

.logo-mark path:nth-child(3) {
  stroke: #4bd3f5;
}

.upgrade-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(47, 116, 246, 0.08);
  font-weight: 900;
}

.home-screen {
  display: grid;
  gap: 14px;
}

.hero-card {
  min-height: 190px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 18px 0;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.95), rgba(235, 244, 255, 0.86)),
    var(--card);
  box-shadow: var(--shadow);
  direction: ltr;
}

.hero-copy {
  padding-bottom: 26px;
  min-width: 0;
  direction: rtl;
}

.hero-copy h1 {
  position: relative;
  isolation: isolate;
  margin: 8px 0 12px;
  font-size: 1.5rem;
  line-height: 1.45;
  letter-spacing: 0;
}

.hero-title-brand { position: relative; z-index: 1; }

.hero-title-icon {
  width: 44px;
  height: 44px;
  position: absolute;
  top: -13px;
  right: -12px;
  z-index: 0;
  margin: 0;
  background: linear-gradient(145deg, #bde3ff 0%, #5a9cff 35%, #1464e7 67%, #093ea9 100%);
  clip-path: polygon(50% 0%, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0% 50%, 39% 35%);
  filter: drop-shadow(0 5px 5px rgba(25, 95, 220, 0.22));
  opacity: .52;
  transform: rotate(10deg);
}

.hero-title-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
}

.hero-copy p {
  margin: 0;
  color: #637084;
  font-size: 0.92rem;
  line-height: 2.05;
}

.primary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 0 24px;
  color: white;
  background: linear-gradient(135deg, #2f7cff, #1262ef);
  box-shadow: 0 14px 24px rgba(31, 106, 239, 0.28);
  font-weight: 900;
}

.hero-copy .primary-button {
  margin-top: 18px;
  min-width: 132px;
}

.primary-button span {
  font-size: 1.5rem;
  line-height: 1;
}

.hero-copy .primary-button__arrow {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  margin-inline-start: 3px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .16);
}

.hero-copy .primary-button__arrow svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.7;
}

.hero-visual {
  align-self: end;
  min-width: 0;
  overflow: hidden;
}

.hero-visual img {
  width: 128%;
  max-width: none;
  transform: translateX(10%) translateY(4px);
  display: block;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.feature-card {
  min-height: 150px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  justify-items: start;
  gap: 8px;
  border: 1px solid #edf1f7;
  border-radius: var(--radius);
  padding: 16px;
  text-align: right;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 22px 48px rgba(34, 66, 115, 0.14);
}

.feature-card img {
  width: 58px;
  height: 58px;
  padding: 2px;
  border-radius: 8px;
  background: #f9fbff;
  box-shadow: inset 0 0 0 1px rgba(222, 229, 240, 0.9);
}

.feature-card strong {
  width: 100%;
  color: #10192c;
  font-size: 1rem;
  line-height: 1.6;
}

.feature-card small {
  width: 100%;
  color: #6f7887;
  font-size: 0.82rem;
  line-height: 1.9;
}

.arrow {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 900;
}

.purple .arrow {
  color: var(--purple);
  background: #f2eaff;
}

.blue .arrow,
.sky .arrow {
  color: var(--blue);
  background: #edf4ff;
}

.green .arrow {
  color: var(--green);
  background: #eafbf3;
}

.amber .arrow {
  color: var(--amber);
  background: #fff4df;
}

.rose .arrow {
  color: var(--rose);
  background: #ffedf2;
}

.trust-card {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  border: 1px solid #edf1f7;
  border-radius: var(--radius);
  padding: 14px 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.trust-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.94rem;
}

.trust-card p {
  margin: 0;
  color: #6f7887;
  font-size: 0.78rem;
  line-height: 1.8;
}

.shield-icon,
.lock-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef5ff;
}

.shield-icon {
  color: white;
  background: linear-gradient(135deg, #61a0ff, #1769f0);
  font-size: 1.35rem;
  font-weight: 950;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  width: min(calc(100% - 28px), 402px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  border: 1px solid #edf1f7;
  border-radius: 28px;
  padding: 10px 8px 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(22, 38, 70, 0.12);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 3px;
  position: relative;
  color: #20283a;
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.4;
}

.bottom-nav span {
  font-size: 1.45rem;
}

.bottom-nav a.active {
  color: var(--blue);
  font-weight: 900;
}

.bottom-nav a.active::after {
  content: "";
  width: 36px;
  height: 4px;
  position: absolute;
  bottom: -9px;
  border-radius: 99px;
  background: var(--blue);
}

.modal-backdrop,
.loading-page,
.chat-page {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
}

.modal-backdrop.is-open,
.loading-page.is-open,
.chat-page.is-open {
  display: grid;
}

.modal-backdrop {
  place-items: center;
  padding: 18px;
  background: rgba(22, 31, 45, 0.36);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(748px, 100%);
  max-height: min(90vh, 842px);
  overflow: hidden;
  border-radius: 34px;
  background: white;
  box-shadow: 0 34px 90px rgba(19, 30, 48, 0.32);
}

.modal-header {
  min-height: 128px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 42px;
  background: #eaf3ff;
  direction: ltr;
}

.close-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  color: #667085;
  background: rgba(255, 255, 255, 0.9);
  font-size: 1.65rem;
  line-height: 1;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: right;
  direction: rtl;
}

.modal-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #4e91ff, #1d67ef);
  box-shadow: 0 14px 28px rgba(31, 106, 239, 0.22);
  font-size: 1.2rem;
  font-weight: 950;
}

.modal-title h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  line-height: 1.4;
}

.modal-title p {
  margin: 0;
  color: #667085;
  font-size: 0.9rem;
}

.profile-form {
  max-height: calc(90vh - 128px);
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 18px;
  padding: 36px 48px 42px;
}

.profile-form label {
  display: grid;
  gap: 10px;
  color: #151d2f;
  font-weight: 900;
  font-size: 0.94rem;
}

.label-title {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.profile-form input,
.profile-form select,
.message-form input {
  width: 100%;
  min-height: 60px;
  border: 1px solid #dfe5ee;
  border-radius: 16px;
  padding: 0 18px;
  outline: none;
  color: var(--text);
  background: #fbfcfe;
}

.profile-form input::placeholder {
  color: #b6c0ce;
  font-weight: 700;
}

.profile-form input:focus,
.profile-form select:focus,
.message-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(47, 116, 246, 0.1);
}

.mini-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-inline-start: 4px;
  border-radius: 4px;
  color: white;
  background: #7150ca;
  font-size: 0.72rem;
}

.file-field,
.form-submit,
.form-error {
  grid-column: 1 / -1;
}

.form-error {
  display: none;
  min-height: 64px;
  align-items: center;
  margin: 0;
  border: 1px solid #ffb8b8;
  border-radius: 16px;
  padding: 0 22px;
  color: #ef2c2c;
  background: #fff2f2;
  font-weight: 900;
}

.form-error.is-visible {
  display: flex;
}

.student-id-field .student-id-error {
  display: none;
  margin-top: 7px;
  border: 1px solid #ffb8b8;
  border-radius: 10px;
  padding: 7px 10px;
  color: #d92d35;
  background: #fff3f3;
  direction: rtl;
  font-size: .72rem;
  font-weight: 800;
}

.student-id-field .student-id-error.is-visible { display: block; }
.student-id-field .student-university-note { display:block; margin-top:7px; color:#5575aa; font-size:.71rem; font-weight:700; }
.profile-form input.is-invalid { border-color: #ef535b; background: #fff8f8; box-shadow: 0 0 0 4px rgba(239,83,91,.1); }

.form-submit {
  min-height: 58px;
  border-radius: 16px;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 40;
  display: none;
  width: min(390px, calc(100vw - 36px));
  border-radius: 16px;
  padding: 14px 18px;
  color: white;
  background: #17a86b;
  box-shadow: 0 18px 40px rgba(23, 168, 107, 0.32);
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.8;
}

.toast.is-open {
  display: block;
  animation: slideIn 0.25s ease both;
}

@media (max-width: 560px) {
  .toast {
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    box-sizing: border-box;
    padding: 13px 16px;
    border-radius: 18px;
    font-size: .86rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
    box-shadow: 0 15px 34px rgba(23, 168, 107, 0.36);
  }
}

.loading-page {
  place-items: center;
  text-align: center;
  color: var(--text);
  background: linear-gradient(145deg, #ffffff, #eaf4ff);
}

.loader {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 8px solid rgba(47, 116, 246, 0.14);
  border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}

.loading-page h2 {
  margin: 22px 0 8px;
}

.chat-page {
  grid-template-columns: 310px 1fr;
  gap: 14px;
  padding: 14px;
  background: #f3f7fc;
}

.chat-sidebar,
.messenger {
  border: 1px solid #edf1f7;
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-sidebar {
  padding: 18px;
}

.back-button,
.send-button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  font-weight: 900;
}

.back-button {
  color: var(--blue);
  background: #eef5ff;
}

.match-profile {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 18px;
  text-align: center;
}

.avatar {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, #61a0ff, #1769f0);
  font-size: 2rem;
  font-weight: 900;
}

.match-profile h2,
.match-profile p {
  margin: 0;
}

.match-profile p {
  color: var(--muted);
  line-height: 1.7;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  color: #17a86b;
  background: rgba(23, 168, 107, 0.1);
  font-weight: 900;
}

.online-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #17a86b;
}

.messenger {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.messenger-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid #edf1f7;
}

.messenger-header strong,
.messenger-header span {
  display: block;
}

.messenger-header span {
  color: var(--muted);
  font-size: 0.86rem;
}

.messages {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 78%;
  border-radius: 18px;
  padding: 10px 12px;
  background: #eef5ff;
  animation: rise 0.28s ease both;
}

.bubble.me {
  margin-right: auto;
  color: white;
  background: linear-gradient(135deg, #2f7cff, #1262ef);
}

.bubble small {
  display: block;
  margin-top: 4px;
  color: inherit;
  opacity: 0.72;
}

.message-form {
  display: grid;
  grid-template-columns: 44px 44px 44px 1fr auto;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid #edf1f7;
}

.message-form button:not(.send-button) {
  border: 1px solid #edf1f7;
  border-radius: 14px;
  background: #fbfcfe;
}

.send-button {
  color: white;
  background: var(--blue);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (min-width: 760px) {
  body {
    padding: 22px 0;
  }

  .phone-shell {
    min-height: calc(100vh - 44px);
    border: 1px solid #e6ebf3;
    border-radius: 34px;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 30px 90px rgba(25, 47, 84, 0.14);
  }
}

@media (max-width: 560px) {
  .phone-shell {
    padding-inline: 16px;
  }

  .hero-card {
    min-height: 176px;
    padding: 22px 16px 0;
  }

  .hero-copy h1 {
    font-size: 1.34rem;
  }

  .hero-copy p {
    font-size: 0.86rem;
  }

  .feature-card {
    min-height: 148px;
    padding: 14px;
  }

  .feature-card img {
    width: 54px;
    height: 54px;
  }

  .modal {
    border-radius: 26px;
  }

  .modal-header {
    padding: 24px;
  }

  .profile-form {
    grid-template-columns: 1fr;
    padding: 28px 24px 34px;
  }

  .chat-page {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .messenger {
    min-height: 68vh;
  }

  .message-form {
    grid-template-columns: 40px 40px 40px 1fr;
  }

  .send-button {
    grid-column: 1 / -1;
  }
}

/* Desktop workspace: the app becomes a real dashboard instead of a scaled phone. */
@media (min-width: 900px) {
  body {
    padding: 36px 0;
    background:
      radial-gradient(circle at 92% 8%, rgba(47, 116, 246, 0.16), transparent 26rem),
      radial-gradient(circle at 7% 90%, rgba(105, 69, 225, 0.09), transparent 30rem),
      #f4f7fc;
  }

  .phone-shell {
    width: min(1240px, calc(100% - 64px));
    min-height: calc(100vh - 72px);
    margin: 0 auto;
    padding: 22px 48px 42px 240px;
    overflow: hidden;
    border: 1px solid rgba(224, 231, 242, 0.92);
    border-radius: 34px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 30px 90px rgba(25, 47, 84, 0.14);
  }

  .statusbar {
    display: none;
  }

  .app-header {
    min-height: 76px;
    padding: 0 0 24px;
    direction: rtl;
  }

  .app-header .header-actions { order: -1; }

  .brand {
    font-size: 1.35rem;
  }

  .upgrade-button {
    min-height: 46px;
    padding-inline: 20px;
  }

  .home-screen {
    gap: 22px;
  }

  .hero-card {
    min-height: 300px;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 24px;
    border-radius: 26px;
    padding: 35px 40px 0;
    direction: rtl;
  }

  .hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 0 35px;
  }

  .hero-copy h1 {
    margin: 0 0 14px;
    font-size: clamp(1.9rem, 3vw, 2.7rem);
  }

  .hero-copy p {
    max-width: 620px;
    font-size: 1rem;
    line-height: 2.1;
  }

  .hero-copy .primary-button {
    min-width: 158px;
    margin-top: 22px;
  }

  .hero-visual {
    display: grid;
    align-items: end;
  }

  .hero-visual img {
    width: min(132%, 410px);
    justify-self: center;
    transform: translateY(6px);
  }

  .feature-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .feature-card {
    min-height: 210px;
    border-radius: 22px;
    padding: 20px;
  }

  .feature-card img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
  }

  .feature-card strong {
    font-size: 1.05rem;
  }

  .feature-card small {
    font-size: 0.84rem;
  }

  .trust-card {
    min-height: 94px;
    border-radius: 22px;
    padding: 18px 24px;
  }

  .bottom-nav {
    width: 176px;
    height: auto;
    position: absolute;
    top: 116px;
    right: auto;
    bottom: 28px;
    left: 28px;
    transform: none;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 7px;
    border-radius: 23px;
    padding: 14px 10px;
    background: rgba(255, 255, 255, 0.84);
  }

  .bottom-nav a {
    min-height: 50px;
    grid-template-columns: 34px 1fr;
    align-items: center;
    justify-items: start;
    gap: 8px;
    border-radius: 13px;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  .bottom-nav span {
    font-size: 1.28rem;
  }

  .bottom-nav a.active {
    background: #edf4ff;
  }

  .bottom-nav a.active::after {
    width: 4px;
    height: 28px;
    right: -10px;
    bottom: auto;
    border-radius: 99px;
  }

  .modal {
    width: min(880px, calc(100% - 80px));
  }

  .chat-page {
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 22px;
    padding: 30px;
  }
}

@media (min-width: 900px) and (max-width: 1080px) {
  .phone-shell {
    width: calc(100% - 36px);
    padding-right: 30px;
  }

  .feature-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* The older match chat is still reachable from the home flow.  On a mobile
   keyboard it must use the visible viewport rather than the full document. */
@media (max-width: 767px) {
  .chat-page.is-open {
    position: fixed;
    top: var(--chat-visual-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    z-index: 2147483000;
    width: 100%;
    height: var(--chat-visual-height, 100dvh);
    min-height: 0;
    display: block;
    overflow: hidden;
    padding: 0;
    background: #f7faff;
  }

  .chat-page.is-open .chat-sidebar { display: none; }
  .chat-page.is-open .messenger {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-page.is-open .messages {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
  }

  .chat-page.is-open .message-form {
    grid-template-columns: 40px minmax(0, 1fr) 44px;
    gap: 8px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    background: #fff;
  }

  .chat-page.is-open .message-form button:nth-child(2),
  .chat-page.is-open .message-form button:nth-child(3) { display: none; }
  .chat-page.is-open .message-form .send-button { grid-column: auto; }
  .chat-page.is-open.keyboard-open .messenger-header { min-height: 56px; }
}

/* User profile workspace */
.user-panel { position:fixed; inset:0; z-index:70; display:none; place-items:center; padding:22px; background:rgba(24,39,71,.34); backdrop-filter:blur(8px); }
.user-panel.is-open { display:grid; animation:panelFade .25s ease both; }
.user-panel__shell { width:min(1100px,100%); max-height:min(850px,calc(100vh - 44px)); display:grid; grid-template-rows:auto 1fr; overflow:hidden; border:1px solid rgba(255,255,255,.8); border-radius:30px; background:#f7faff; box-shadow:0 35px 90px rgba(19,30,48,.3); }
.user-panel__header { min-height:88px; display:flex; align-items:center; gap:16px; padding:16px 28px; color:#fff; background:linear-gradient(115deg,#2668ed,#4b91ff); }.user-panel__header div { margin-left:auto; }.user-panel__header span { display:block; opacity:.76; font-size:.75rem; }.user-panel__header h2 { margin:3px 0 0; font-size:1.25rem; }.user-panel__close { width:42px; height:42px; border:0; border-radius:50%; color:#4a5c78; background:#fff; font-size:1.7rem; cursor:pointer; }.user-panel__signout { min-height:38px; border:1px solid rgba(255,255,255,.55); border-radius:11px; padding:0 13px; color:#fff; background:rgba(255,255,255,.14); font:inherit; font-size:.76rem; font-weight:800; cursor:pointer; }
.user-panel__content { min-height:0; display:grid; grid-template-columns:250px minmax(0,1fr); overflow:auto; }.user-panel__aside { display:flex; flex-direction:column; align-items:center; padding:30px 20px; border-left:1px solid #e7edf7; text-align:center; background:linear-gradient(180deg,#eff6ff,#fbfdff); }.profile-avatar-picker { width:104px; height:104px; position:relative; display:grid; place-items:center; overflow:hidden; border:5px solid #fff; border-radius:50%; color:#fff; background:linear-gradient(135deg,#5da3ff,#2b66df); box-shadow:0 13px 26px rgba(43,102,223,.25); cursor:pointer; }.profile-avatar-picker img { width:100%; height:100%; object-fit:cover; }.profile-avatar-picker span { font-size:2.7rem; font-weight:900; }.profile-avatar-picker input { display:none; }.profile-avatar-picker b { width:30px; height:30px; position:absolute; bottom:0; right:0; display:grid; place-items:center; border:2px solid #fff; border-radius:50%; background:#172b56; font-size:.8rem; }.user-panel__aside h3 { margin:15px 0 4px; color:#172b56; font-size:.98rem; }.user-panel__aside p { margin:0; color:#7e8ba2; font-size:.72rem; }.profile-active { display:inline-flex; align-items:center; gap:5px; margin:12px 0 22px; border-radius:999px; padding:6px 10px; color:#168454; background:#e8fbf2; font-size:.68rem; font-weight:800; }.profile-active i { width:7px; height:7px; border-radius:50%; background:#20bd78; }.user-panel__menu { width:100%; display:grid; gap:6px; }.user-panel__menu button { min-height:42px; border:0; border-radius:11px; padding:0 11px; color:#52637e; background:transparent; text-align:right; font:inherit; font-size:.75rem; font-weight:700; cursor:pointer; }.user-panel__menu button.is-active,.user-panel__menu button:hover { color:#2363e8; background:#e2eeff; }
.user-panel__main { padding:30px; background:#fff; }.profile-welcome { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding-bottom:22px; }.profile-welcome p { margin:0; color:#61718a; font-size:.85rem; }.profile-welcome h1 { margin:6px 0; color:#17264a; font-size:1.24rem; }.profile-welcome small { color:#8895a8; font-size:.7rem; }.profile-complete { flex:0 0 auto; border-radius:10px; padding:7px 10px; color:#1d72d9; background:#edf5ff; font-size:.67rem; font-weight:850; }.profile-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:24px; }.profile-stats article { display:flex; align-items:center; gap:10px; min-height:69px; border:1px solid #e9eef7; border-radius:15px; padding:10px 12px; background:#fbfcff; }.profile-stats article>span { width:36px; height:36px; display:grid; place-items:center; border-radius:11px; background:#edf4ff; font-size:1.05rem; }.profile-stats b,.profile-stats small { display:block; }.profile-stats b { color:#1c315e; font-size:.91rem; }.profile-stats small { margin-top:3px; color:#8995a7; font-size:.64rem; }.user-panel__form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }.user-panel__form h2,.user-panel__error,.user-panel__security,.user-panel__save { grid-column:1 / -1; }.user-panel__form h2 { margin:4px 0 0; color:#1a2d55; font-size:1rem; }.user-panel__form label { display:grid; gap:7px; color:#43516a; font-size:.73rem; font-weight:850; }.user-panel__form input,.user-panel__form select { width:100%; min-height:44px; border:1px solid #e1e8f3; border-radius:11px; padding:0 12px; outline:0; color:#1b2d53; background:#fbfcff; font:inherit; font-size:.78rem; }.user-panel__form input:focus,.user-panel__form select:focus { border-color:#2a6fea; box-shadow:0 0 0 3px rgba(42,111,234,.1); }.user-panel__error { min-height:0; margin:0; color:#df4b4b; font-size:.72rem; font-weight:700; }.user-panel__security { display:flex; align-items:center; gap:9px; border-radius:12px; padding:12px; color:#68778e; background:#f3f7fd; font-size:.7rem; }.user-panel__security b { color:#32486f; }.user-panel__save { min-height:48px; border-radius:13px; }
@keyframes panelFade { from { opacity:0; transform:scale(.985); } to { opacity:1; transform:none; } }
@media (max-width:700px) { .user-panel { padding:0; }.user-panel__shell { width:100%; max-height:100vh; min-height:100vh; border:0; border-radius:0; }.user-panel__header { min-height:72px; padding:12px 18px; }.user-panel__header h2 { font-size:1.05rem; }.user-panel__signout { padding:0 9px; font-size:.67rem; }.user-panel__content { grid-template-columns:1fr; }.user-panel__aside { display:grid; grid-template-columns:auto 1fr; justify-items:start; column-gap:13px; padding:18px; border-bottom:1px solid #e7edf7; border-left:0; text-align:right; }.profile-avatar-picker { grid-row:span 3; width:65px; height:65px; }.profile-avatar-picker span { font-size:1.8rem; }.user-panel__aside h3 { align-self:end; margin:0; }.user-panel__aside p { align-self:start; }.profile-active { align-self:start; margin:4px 0 0; }.user-panel__menu { display:none; }.user-panel__main { padding:22px 18px 30px; }.profile-welcome h1 { font-size:1rem; }.profile-welcome small { display:none; }.profile-stats { gap:7px; }.profile-stats article { justify-content:center; padding:8px; }.profile-stats article>span { display:none; }.user-panel__form { grid-template-columns:1fr; gap:13px; }.user-panel__form h2,.user-panel__error,.user-panel__security,.user-panel__save { grid-column:auto; }.user-panel__security { align-items:flex-start; flex-direction:column; } }
