:root {
  --portal-bg: #f3f6fb;
  --portal-bg-2: #eef3f9;
  --portal-surface: rgba(255, 255, 255, 0.92);
  --portal-surface-strong: #ffffff;
  --portal-surface-soft: #f8fafc;
  --portal-border: rgba(17, 24, 39, 0.08);
  --portal-border-strong: rgba(17, 24, 39, 0.14);
  --portal-text: #0f172a;
  --portal-text-soft: #475569;
  --portal-text-faint: #64748b;
  --portal-shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.06);
  --portal-shadow-md: 0 18px 45px rgba(15, 23, 42, 0.1);
  --portal-shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.14);
  --portal-radius-xl: 30px;
  --portal-radius-lg: 22px;
  --portal-radius-md: 18px;
  --portal-radius-sm: 14px;
  --portal-gold: #c78d2d;
  --portal-gold-strong: #a86f15;
  --portal-gold-soft: #f8edd7;
  --portal-navy: #10243f;
  --portal-navy-2: #18385f;
  --portal-success-bg: #ecfdf3;
  --portal-success-border: #9de4b7;
  --portal-success-text: #166534;
  --portal-danger-bg: #fff1f2;
  --portal-danger-border: #fda4af;
  --portal-danger-text: #be123c;
  --portal-warning-bg: #fff7ed;
  --portal-warning-border: #fdba74;
  --portal-warning-text: #9a3412;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.portal-body {
  min-height: 100vh;
  color: var(--portal-text);
  background:
    radial-gradient(circle at top left, rgba(199, 141, 45, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(24, 56, 95, 0.12), transparent 22%),
    linear-gradient(180deg, var(--portal-bg) 0%, #f7f9fc 48%, #eef3f9 100%);
}

.portal-top-header {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.portal-top-header::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
}

.portal-top-header .header-bar {
  width: min(1320px, calc(100% - 32px));
  margin-inline: auto;
}

.portal-top-header .nav-cta.ghost {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: none;
  color: #fff;
}

.portal-top-header .nav-cta.ghost:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.28);
}

.portal-shell {
  position: relative;
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto 56px;
  padding-top: calc(var(--header-h) + 34px);
}

.portal-shell::before,
.portal-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  opacity: 0.55;
}

.portal-shell::before {
  width: 160px;
  height: 160px;
  top: 48px;
  right: 0;
  background: rgba(199, 141, 45, 0.15);
}

.portal-shell::after {
  width: 140px;
  height: 140px;
  left: -24px;
  top: 420px;
  background: rgba(16, 36, 63, 0.08);
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 26px;
  align-items: stretch;
  padding: 8px 0 30px;
}

.portal-hero > div:first-child {
  position: relative;
  padding: 34px 34px 30px;
  border-radius: var(--portal-radius-xl);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,255,255,0.88)),
    linear-gradient(180deg, rgba(199, 141, 45, 0.05), rgba(24, 56, 95, 0.06));
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: var(--portal-shadow-lg);
  overflow: hidden;
}

.portal-hero > div:first-child::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 18%, rgba(199, 141, 45, 0.14), transparent 16%),
    radial-gradient(circle at 15% 100%, rgba(16, 36, 63, 0.08), transparent 25%);
  pointer-events: none;
}

.portal-hero .section-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--portal-gold-soft);
  color: var(--portal-gold-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.portal-hero h1 {
  margin: 0 0 16px;
  max-width: 760px;
  font-size: clamp(2rem, 3.4vw, 3.45rem);
  line-height: 1.04;
  color: #0b1d33;
}

.portal-hero p {
  max-width: 760px;
  margin: 0;
  font-size: 1rem;
  line-height: 1.85;
  color: var(--portal-text-soft);
}

.portal-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.portal-hero-badges span,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--portal-border);
  color: var(--portal-text);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  font-size: 0.86rem;
  font-weight: 700;
}

.status-pill {
  background: linear-gradient(135deg, #f8ecd4, #fffaf1);
  border-color: rgba(199, 141, 45, 0.24);
  color: var(--portal-gold-strong);
  white-space: nowrap;
}

.how-it-works-card {
  position: relative;
  padding: 30px;
  border-radius: var(--portal-radius-xl);
  background:
    radial-gradient(circle at top right, rgba(255,255,255,0.1), transparent 18%),
    linear-gradient(180deg, var(--portal-navy) 0%, var(--portal-navy-2) 100%);
  box-shadow: var(--portal-shadow-lg);
  overflow: hidden;
}

.how-it-works-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.06), transparent 36%),
    radial-gradient(circle at bottom left, rgba(199, 141, 45, 0.18), transparent 22%);
  pointer-events: none;
}

.how-it-works-card h3 {
  position: relative;
  margin: 0 0 18px;
  font-size: 1.35rem;
  color: #fff;
}

.step-item {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.step-item:first-of-type {
  padding-top: 8px;
  border-top: none;
}

.step-item span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  font-weight: 800;
}

.step-item p {
  margin: 0;
  color: rgba(255,255,255,0.82);
  line-height: 1.8;
}

.portal-grid {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.portal-main {
  display: grid;
  gap: 24px;
}

.portal-card {
  position: relative;
  border-radius: var(--portal-radius-xl);
  border: 1px solid rgba(255,255,255,0.72);
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(255,255,255,0.9) 100%);
  box-shadow: var(--portal-shadow-md);
  padding: 26px;
  overflow: hidden;
}

.portal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(248,250,252,0.45), rgba(248,250,252,0));
  pointer-events: none;
}

.card-head,
.auth-tabs,
.alert-box,
.locked-dashboard-note,
.auth-form,
.profile-grid,
.ai-app-actions,
.conversation-list,
.chat-layout {
  position: relative;
  z-index: 1;
}

.card-head {
  margin-bottom: 18px;
}

.card-head h2 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 2vw, 1.7rem);
  line-height: 1.15;
  color: #0c1d33;
}

.card-head p,
.chat-panel-head p,
#conversationMeta {
  margin: 0;
  color: var(--portal-text-soft);
  line-height: 1.75;
}

.card-head.split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.auth-card {
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 18px;
}

.auth-tab,
.portal-btn {
  border: none;
  border-radius: 16px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  font-family: inherit;
  font-weight: 700;
}

.auth-tab {
  min-height: 50px;
  padding: 0 14px;
  background: linear-gradient(180deg, #f7f9fc 0%, #edf3f9 100%);
  color: var(--portal-text);
  border: 1px solid transparent;
  cursor: pointer;
}

.auth-tab:hover,
.portal-btn:hover {
  transform: translateY(-1px);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--portal-gold), #e9b864);
  color: #fff;
  box-shadow: 0 14px 24px rgba(199, 141, 45, 0.24);
}

.auth-form {
  display: none;
  gap: 14px;
}

.auth-form.active {
  display: grid;
}

.auth-form label,
.profile-grid label,
.new-conversation-form label {
  display: grid;
  gap: 8px;
  color: var(--portal-text);
  font-size: 0.88rem;
  font-weight: 700;
}

.auth-form input,
.profile-grid input,
.new-conversation-form input,
.new-conversation-form select,
.message-form textarea,
.message-actions input[type="file"] {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  outline: none;
  background: rgba(255,255,255,0.98);
  color: var(--portal-text);
  padding: 15px 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-form input::placeholder,
.profile-grid input::placeholder,
.new-conversation-form input::placeholder,
.message-form textarea::placeholder {
  color: #94a3b8;
}

.auth-form input:focus,
.profile-grid input:focus,
.new-conversation-form input:focus,
.new-conversation-form select:focus,
.message-form textarea:focus,
.message-actions input[type="file"]:focus {
  border-color: rgba(199, 141, 45, 0.55);
  box-shadow: 0 0 0 4px rgba(199, 141, 45, 0.12);
}

.new-conversation-form select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 22px) calc(50% - 3px), calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

.message-form textarea {
  min-height: 126px;
  resize: vertical;
  line-height: 1.8;
}

.portal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 18px;
  text-decoration: none;
  cursor: pointer;
}

.portal-btn.primary {
  background: linear-gradient(135deg, var(--portal-gold), #e6b25b);
  color: #fff;
  box-shadow: 0 16px 28px rgba(199, 141, 45, 0.22);
}

.portal-btn.primary:hover {
  box-shadow: 0 20px 32px rgba(199, 141, 45, 0.28);
}

.portal-btn.secondary,
.portal-btn.tiny {
  background: linear-gradient(180deg, #f8fafc 0%, #eef3f9 100%);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--portal-text);
}

.portal-btn.tiny {
  min-height: 44px;
  padding-inline: 16px;
  font-size: 0.84rem;
}

.alert-box {
  display: none;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.75;
  border: 1px solid transparent;
}

.alert-box.show {
  display: block;
}

.alert-box.success {
  background: var(--portal-success-bg);
  color: var(--portal-success-text);
  border-color: var(--portal-success-border);
}

.alert-box.error {
  background: var(--portal-danger-bg);
  color: var(--portal-danger-text);
  border-color: var(--portal-danger-border);
}

.locked-dashboard-note {
  margin-top: 16px;
  border-radius: 18px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #fff8ef 0%, #fff2df 100%);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--portal-warning-text);
  font-size: 0.92rem;
  line-height: 1.8;
}

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

.profile-actions {
  display: flex;
  align-items: end;
}

.ai-app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 6px 0 20px;
}

.ai-link-btn {
  text-decoration: none;
}

.chat-card {
  padding-bottom: 24px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 345px minmax(0, 1fr);
  gap: 22px;
  margin-top: 14px;
  align-items: start;
}

.conversation-sidebar,
.chat-panel {
  min-width: 0;
}

.new-conversation-form {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8fc 100%);
  border: 1px solid var(--portal-border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
  margin-bottom: 16px;
}

.conversation-list,
.message-list {
  border-radius: 24px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--portal-border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85);
  overflow: auto;
}

.conversation-list {
  min-height: 260px;
  max-height: 600px;
}

.message-list {
  min-height: 400px;
  max-height: 640px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    linear-gradient(180deg, rgba(250,252,255,0.98) 0%, rgba(247,250,252,0.98) 100%),
    radial-gradient(circle at top right, rgba(199,141,45,0.06), transparent 14%);
}

.conversation-item {
  display: grid;
  gap: 6px;
  padding: 16px 17px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.conversation-item:last-child {
  border-bottom: none;
}

.conversation-item:hover {
  background: #f8fbff;
}

.conversation-item.active {
  background: linear-gradient(180deg, #fff9ee 0%, #fff4df 100%);
  border-color: rgba(199, 141, 45, 0.22);
}

.conversation-item strong,
.message-bubble strong {
  display: block;
  color: #10213a;
  line-height: 1.5;
}

.conversation-item strong {
  font-size: 0.98rem;
}

.conversation-item small,
.empty-state,
.empty-state.small {
  color: var(--portal-text-faint);
  line-height: 1.65;
}

.empty-state {
  padding: 44px 22px;
  text-align: center;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 20px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(250,252,255,0.95) 100%);
  border: 1px solid rgba(255,255,255,0.72);
  box-shadow: 0 22px 55px rgba(15, 23, 42, 0.1);
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
}

.chat-panel-head h3 {
  margin: 0 0 4px;
  font-size: 1.22rem;
  line-height: 1.25;
  color: #0e1f35;
}

.chat-card > .card-head.split {
  margin-bottom: 16px;
}

.chat-card > .card-head.split + .chat-layout .chat-panel > div[style] {
  margin: 0 0 16px !important;
  border-radius: 18px !important;
  padding: 16px 18px !important;
  line-height: 1.8 !important;
  font-size: 0.92rem !important;
}

.message-bubble {
  width: fit-content;
  max-width: min(78%, 700px);
  padding: 16px 18px;
  border-radius: 20px 20px 20px 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fafc 100%);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--portal-text);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
  line-height: 1.8;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message-bubble.mine {
  margin-left: auto;
  border-radius: 20px 20px 8px 20px;
  background: linear-gradient(180deg, #fff6e7 0%, #ffefcf 100%);
  border-color: rgba(199, 141, 45, 0.2);
}

.message-bubble strong {
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: capitalize;
  letter-spacing: 0.03em;
  color: var(--portal-gold-strong);
}

.message-bubble:not(.mine) strong {
  color: var(--portal-navy-2);
}

.message-bubble > div {
  white-space: pre-wrap;
}

.message-bubble small {
  display: block;
  margin-top: 10px;
  color: var(--portal-text-faint);
  font-size: 0.78rem;
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: 14px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--portal-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.message-file:hover {
  background: #fff;
}

.message-form {
  margin-top: 18px;
}

.message-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.message-actions input[type="file"] {
  min-height: 50px;
  padding: 11px 14px;
  background: #fff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(226, 232, 240, 0.45);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.45);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.65);
}

@media (max-width: 1180px) {
  .portal-grid,
  .portal-hero,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .auth-card {
    position: relative;
    top: 0;
  }

  .chat-panel {
    min-height: 0;
  }
}

@media (max-width: 860px) {
  .portal-shell,
  .portal-top-header .header-bar {
    width: min(100% - 20px, 100%);
  }

  .portal-shell {
    padding-top: calc(var(--header-h) + 22px);
  }

  .portal-hero > div:first-child,
  .how-it-works-card,
  .portal-card,
  .chat-panel {
    border-radius: 24px;
  }

  .portal-hero > div:first-child,
  .how-it-works-card,
  .portal-card,
  .chat-panel,
  .new-conversation-form {
    padding: 22px;
  }

  .profile-card .profile-grid {
    grid-template-columns: 1fr;
  }

  .card-head.split {
    flex-direction: column;
    align-items: stretch;
  }

  .status-pill {
    align-self: flex-start;
  }

  .message-bubble {
    max-width: 88%;
  }
}

@media (max-width: 640px) {
  .portal-hero h1 {
    font-size: 2rem;
  }

  .auth-tabs {
    grid-template-columns: 1fr;
  }

  .portal-card,
  .chat-panel,
  .new-conversation-form,
  .portal-hero > div:first-child,
  .how-it-works-card {
    padding: 18px;
    border-radius: 20px;
  }

  .portal-grid,
  .portal-main,
  .chat-layout {
    gap: 18px;
  }

  .message-list {
    min-height: 320px;
    max-height: 520px;
    padding: 16px;
  }

  .message-bubble {
    max-width: 94%;
    padding: 14px 15px;
  }

  .message-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-btn,
  .portal-btn.tiny {
    width: 100%;
  }
}

/* ===== Portal HTML rewrite ===== */
.portal-shell-redesign {
  padding-bottom: 32px;
}

.portal-hero-redesign {
  align-items: stretch;
}

.hero-copy-card {
  position: relative;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.hero-metrics article {
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 10px 24px rgba(15,23,42,0.05);
}

.hero-metrics strong,
.mini-feature-list span,
.side-panel-title h3 {
  display: block;
  color: var(--portal-text);
}

.hero-metrics span {
  display: block;
  margin-top: 6px;
  color: var(--portal-text-soft);
  font-size: 0.92rem;
  line-height: 1.6;
}

.portal-grid-redesign {
  grid-template-columns: 360px minmax(0, 1fr);
}

.portal-sidebar-stack,
.portal-main-redesign {
  display: grid;
  gap: 24px;
}

.auth-card-redesign,
.portal-mini-card,
.profile-card-redesign,
.chat-card-redesign,
.register-form-card,
.register-copy-card {
  border-radius: 28px;
}

.portal-mini-card {
  padding: 24px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(15,23,42,0.07);
  box-shadow: var(--portal-shadow-md);
}

.card-head.compact h3 {
  margin: 0;
  font-size: 1.1rem;
}

.mini-feature-list {
  display: grid;
  gap: 14px;
}

.mini-feature-list div {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  align-items: start;
  color: var(--portal-text-soft);
  line-height: 1.7;
}

.mini-feature-list i,
.portal-hero-badges i {
  color: var(--portal-gold-strong);
}

.portal-btn-link {
  text-align: center;
  text-decoration: none;
}

.portal-full-btn {
  width: 100%;
  margin-top: 18px;
  text-decoration: none;
}

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

.profile-form-grid label,
.register-page-form label {
  display: grid;
  gap: 8px;
  color: var(--portal-text-soft);
  font-weight: 600;
}

.profile-form-grid input,
.register-page-form input {
  width: 100%;
}

.profile-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
}

.referral-grid-redesign {
  align-items: end;
}

.metrics-row strong {
  color: var(--portal-gold-strong);
}

.ai-app-actions-redesign .portal-btn {
  text-decoration: none;
}

.notice-banner-redesign {
  margin: 0 0 18px;
  padding: 15px 16px;
  border-radius: 18px;
  background: var(--portal-warning-bg);
  border: 1px solid var(--portal-warning-border);
  color: var(--portal-warning-text);
  line-height: 1.75;
}

.chat-layout-redesign {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.conversation-sidebar-redesign,
.chat-panel-redesign {
  min-height: 720px;
  border-radius: 26px;
}

.conversation-sidebar-redesign {
  padding: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(247,250,252,0.92));
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 16px 40px rgba(15,23,42,0.05);
}

.chat-panel-redesign {
  display: flex;
  flex-direction: column;
  padding: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(249,250,252,0.96));
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 18px 48px rgba(15,23,42,0.08);
}

.side-panel-title p,
.chat-panel-head-redesign p {
  margin: 6px 0 0;
  color: var(--portal-text-faint);
  line-height: 1.6;
}

.side-panel-title-spaced {
  margin-top: 22px;
}

.new-conversation-form {
  display: grid;
  gap: 14px;
}

.new-conversation-form label,
.message-textarea-wrap {
  display: grid;
  gap: 8px;
  color: var(--portal-text-soft);
  font-weight: 600;
}

.new-conversation-form select,
.new-conversation-form input,
.message-form-redesign textarea,
.profile-form-grid input,
.register-page-form input,
.auth-form input,
.profile-grid input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,0.12);
  background: #fff;
  color: var(--portal-text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.message-form-redesign textarea {
  min-height: 132px;
  resize: vertical;
}

.new-conversation-form select:focus,
.new-conversation-form input:focus,
.message-form-redesign textarea:focus,
.profile-form-grid input:focus,
.register-page-form input:focus,
.auth-form input:focus,
.profile-grid input:focus {
  border-color: rgba(199,141,45,0.55);
  box-shadow: 0 0 0 4px rgba(199,141,45,0.12);
}

.conversation-list-redesign,
.message-list-redesign,
#referralRewardsList,
#applicationList {
  border-radius: 20px;
}

.conversation-list-redesign {
  display: grid;
  gap: 12px;
  align-content: start;
  max-height: 410px;
  overflow: auto;
  padding-right: 6px;
}

.conversation-item {
  display: grid;
  gap: 6px;
  padding: 16px 16px 15px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 12px 24px rgba(15,23,42,0.04);
}

.conversation-item strong {
  font-size: 0.98rem;
  line-height: 1.5;
}

.conversation-item small {
  color: var(--portal-text-faint);
  line-height: 1.5;
}

.conversation-item.active {
  border-color: rgba(199,141,45,0.42);
  background: linear-gradient(180deg, #fffdf8, #fffaf1);
  box-shadow: 0 18px 30px rgba(199,141,45,0.12);
}

.chat-panel-head-redesign {
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(15,23,42,0.08);
}

.chat-panel-head-redesign h3 {
  margin: 0;
  font-size: 1.3rem;
}

.message-list-redesign {
  flex: 1;
  overflow: auto;
  margin: 18px 0;
  padding: 6px 4px 6px 2px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-bubble {
  max-width: min(78%, 720px);
  padding: 18px 18px 16px;
  border-radius: 22px 22px 22px 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid rgba(15,23,42,0.08);
  box-shadow: 0 16px 30px rgba(15,23,42,0.06);
}

.message-bubble.mine {
  align-self: flex-end;
  border-radius: 22px 22px 8px 22px;
  background: linear-gradient(180deg, #fff8ea, #fffdf7);
  border-color: rgba(199,141,45,0.22);
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.message-meta strong {
  font-size: 0.95rem;
  text-transform: capitalize;
}

.message-meta small {
  color: var(--portal-text-faint);
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.9;
  color: var(--portal-text);
  font-size: 0.97rem;
}

.message-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--portal-navy-2);
  text-decoration: none;
  font-weight: 700;
}

.message-actions-redesign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.message-actions-redesign input[type="file"] {
  max-width: 100%;
}

.auth-page-body .portal-shell {
  margin-bottom: 0;
}

.auth-shell-redesign {
  display: flex;
  align-items: center;
  min-height: 100vh;
}

.register-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(400px, 0.95fr);
  gap: 26px;
  width: 100%;
  align-items: stretch;
}

.register-copy-card {
  padding: 38px;
  background: linear-gradient(180deg, rgba(16,36,63,0.98), rgba(24,56,95,0.96));
  color: #fff;
  box-shadow: var(--portal-shadow-lg);
}

.register-copy-card h1 {
  margin: 14px 0 14px;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1.05;
}

.register-copy-card p {
  margin: 0 0 22px;
  color: rgba(255,255,255,0.82);
  line-height: 1.9;
}

.register-copy-card .section-label {
  background: rgba(255,255,255,0.12);
  color: #fff3d7;
}

.register-copy-card .mini-feature-list div {
  color: rgba(255,255,255,0.84);
}

.register-copy-card .mini-feature-list i {
  color: #ffd38a;
}

.register-form-card {
  padding: 30px;
}

.register-page-form {
  display: grid;
  gap: 16px;
}

.register-page-form .portal-btn,
.auth-form .portal-btn {
  width: 100%;
}

@media (max-width: 1100px) {
  .portal-grid-redesign,
  .chat-layout-redesign,
  .register-layout {
    grid-template-columns: 1fr;
  }

  .hero-metrics,
  .profile-form-grid {
    grid-template-columns: 1fr;
  }

  .conversation-sidebar-redesign,
  .chat-panel-redesign {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .portal-shell,
  .portal-top-header .header-bar {
    width: min(100% - 18px, 100%);
  }

  .portal-hero > div:first-child,
  .how-it-works-card,
  .conversation-sidebar-redesign,
  .chat-panel-redesign,
  .register-copy-card,
  .register-form-card {
    padding: 22px;
    border-radius: 22px;
  }

  .portal-grid,
  .portal-main,
  .portal-sidebar-stack,
  .portal-main-redesign {
    gap: 18px;
  }

  .message-bubble {
    max-width: 100%;
    padding: 16px;
  }

  .message-actions-redesign {
    align-items: stretch;
  }
}
