/* Companion Cabin dashboard styles */
.cabin-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #0B0F19;
}

.cabin-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 0;
}

@media (max-width: 900px) {
  .cabin-body {
    grid-template-columns: 1fr;
  }
  .cabin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }
  .cabin-sidebar.open { transform: translateX(0); }
  .cabin-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 35;
  }
  .cabin-sidebar-backdrop.show { display: block; }
}

.cabin-sidebar {
  background: #111827;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.char-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}
.char-card:hover { background: rgba(139, 92, 246, 0.08); }
.char-card.active {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.14);
  box-shadow: 0 0 24px rgba(139, 92, 246, 0.15);
}

.char-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.cabin-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(ellipse 60% 40% at 80% 0%, rgba(139, 92, 246, 0.12), transparent),
    #0B0F19;
}

.chat-scroll {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  min-height: 0;
  flex: 1 1 auto;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}

.msg-row {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  width: 100%;
  max-width: 100%;
  align-items: flex-end;
  box-sizing: border-box;
}
.msg-row.user {
  flex-direction: row-reverse;
}

.msg-bubble {
  flex: 0 1 auto;
  min-width: 2.75rem;
  max-width: min(85%, 36rem);
  padding: 0.7rem 0.95rem;
  border-radius: 1rem;
  line-height: 1.55;
  font-size: 0.925rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
  box-sizing: border-box;
}
.msg-row.ai .msg-bubble {
  background: #151C2C;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-top-left-radius: 0.3rem;
  color: #E5E7EB;
}
.msg-row.user .msg-bubble {
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  border-top-right-radius: 0.3rem;
  color: #fff !important;
}

.msg-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-width: 0;
  max-width: min(85%, 36rem);
}
.msg-row.user .msg-bubble-wrap {
  align-items: flex-end;
}

.msg-bubble-wrap .msg-bubble {
  max-width: 100%;
}

.msg-actions {
  display: flex;
  gap: 0.35rem;
  opacity: 0.55;
}
.msg-row:hover .msg-actions,
.msg-row:focus-within .msg-actions {
  opacity: 1;
}
.msg-action-btn {
  border: none;
  background: transparent;
  color: #9CA3AF;
  font-size: 0.7rem;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  border-radius: 0.35rem;
}
.msg-action-btn:hover {
  color: #F472B6;
  background: rgba(255, 255, 255, 0.06);
}

.msg-image {
  display: block;
  width: 100%;
  max-width: min(100%, 320px);
  height: auto;
  max-height: 420px;
  object-fit: cover;
  border-radius: 0.75rem;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0B0F19;
}

.msg-photo-fallback {
  color: #C4B5FD;
  font-style: normal;
  font-size: 0.85rem;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.typing-row {
  display: none;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  padding: 0 1rem 0.35rem;
  color: #A78BFA;
  font-size: 0.85rem;
}
.typing-row.show { display: flex; }
.typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 3px;
  border-radius: 50%;
  background: #8B5CF6;
  animation: tb 1.2s infinite ease-in-out both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

.chat-composer {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(12px);
  padding: 0.85rem 1rem 1rem;
}

.composer-box {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: #151C2C;
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 1rem;
  padding: 0.5rem;
}

.composer-box textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: #F3F4F6;
  font-size: 0.95rem;
  line-height: 1.45;
  max-height: 140px;
  padding: 0.55rem 0.4rem;
}

.auth-modal,
.premium-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-modal.open,
.premium-modal.open { display: flex; }
.auth-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 25, 0.82);
  backdrop-filter: blur(8px);
}
.auth-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 1.5rem;
  background: #151C2C;
  border-radius: 1rem;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  background: #0B0F19;
  padding: 0.25rem;
  border-radius: 0.75rem;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #9CA3AF;
  padding: 0.55rem;
  border-radius: 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-tab.active {
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
  color: #fff;
}

/* AiNastia gender onboarding (signup first step) */
.onboard-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.onboard-modal.open { display: flex; }
.onboard-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  padding: 1.35rem 1.35rem 1.5rem;
  border-radius: 1.35rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(139, 92, 246, 0.35), transparent 60%),
    linear-gradient(165deg, #5B21B6 0%, #4C1D95 40%, #2E1065 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  color: #fff;
}
.onboard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.onboard-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
}
.onboard-mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, #A78BFA, #EC4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
}
.onboard-signin {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
}
.onboard-title {
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.15rem, 3.5vw, 1.55rem);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 1.25rem;
}
.onboard-title .hl {
  color: #C8F542;
}
.onboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.onboard-card {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 1rem;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  padding: 0;
  text-align: left;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.onboard-card:hover,
.onboard-card.is-selected {
  border-color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.onboard-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.onboard-card-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.75rem 0.75rem 0.85rem;
  background: linear-gradient(to top, rgba(15, 10, 40, 0.95), transparent);
  text-align: center;
}
.onboard-card-label strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}
.onboard-card-label span {
  display: block;
  font-size: 0.68rem;
  opacity: 0.85;
  letter-spacing: 0.04em;
  margin-top: 0.15rem;
}
.onboard-card--wide {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 4.5rem;
  padding: 0.55rem 0.85rem;
}
.onboard-card--wide img {
  width: 3.75rem;
  height: 3.75rem;
  aspect-ratio: 1;
  border-radius: 0.65rem;
  object-fit: cover;
  flex-shrink: 0;
}
.onboard-card--wide .onboard-card-label {
  position: static;
  background: none;
  padding: 0;
  text-align: left;
}
.onboard-hint {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 0.85rem;
}
@media (max-width: 420px) {
  .onboard-grid { gap: 0.55rem; }
  .onboard-card-label strong { font-size: 0.8rem; }
}

.field {
  margin-bottom: 0.85rem;
}
.field label {
  display: block;
  font-size: 0.78rem;
  color: #9CA3AF;
  margin-bottom: 0.35rem;
}
.field input {
  width: 100%;
  background: #0B0F19;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.65rem;
  padding: 0.7rem 0.85rem;
  color: #fff;
  font-size: 0.9rem;
}
.field input:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.55);
}

.settings-select {
  width: 100%;
  background: #0B0F19;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.65rem;
  padding: 0.7rem 0.85rem;
  color: #fff;
  font-size: 0.9rem;
}
.settings-select:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.55);
}

.companion-pick {
  position: relative;
  text-align: left;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(21, 28, 44, 0.55);
  cursor: pointer;
  color: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.companion-pick:hover {
  border-color: rgba(139, 92, 246, 0.45);
  background: rgba(139, 92, 246, 0.1);
}
.companion-pick.is-selected {
  border-color: rgba(167, 139, 250, 0.9);
  background: rgba(139, 92, 246, 0.18);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.35), 0 10px 28px rgba(0, 0, 0, 0.25);
}
.companion-pick-check {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0B0F19;
  background: #C8F542;
}
.companion-pick.is-selected .companion-pick-check {
  display: flex;
}

.credits-pill {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #C4B5FD;
}

.gate-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
  text-align: center;
}

/* Homepage hero embed — larger responsive cabin */
.cabin-shell--embed {
  position: relative;
  width: 100%;
  height: clamp(520px, 70vh, 720px);
  min-height: 480px;
  max-height: none;
  border-radius: 1.15rem;
  border: 1px solid rgba(139, 92, 246, 0.28);
  overflow: hidden;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: 1fr;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 20px 50px rgba(0, 0, 0, 0.45),
    0 0 40px rgba(139, 92, 246, 0.1);
}

.cabin-shell--embed > header {
  grid-row: 1;
  z-index: 70;
  min-width: 0;
  overflow: visible;
  gap: 0.35rem;
  position: relative;
  pointer-events: auto;
}

.cabin-shell--embed #user-menu-btn,
.cabin-shell--embed .cabin-me-wrap {
  position: relative;
  z-index: 80;
  pointer-events: auto;
  flex-shrink: 0;
}

/* Account menu — portaled to body + fixed */
#user-menu.user-menu--fixed,
#user-menu.open {
  position: fixed !important;
  top: auto;
  right: auto;
  z-index: 10000 !important;
  max-width: min(14rem, calc(100vw - 1rem));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  background: #151C2C;
  pointer-events: auto;
}

.cabin-shell--embed > header > * {
  min-width: 0;
}

.cabin-shell--embed #user-email-label {
  display: none !important;
}

.cabin-shell--embed #credits-label {
  display: none !important;
}

.cabin-shell--embed #active-companion-title {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cabin-shell--embed > .cabin-body {
  grid-row: 2;
  min-height: 0;
  height: 100%;
  display: flex !important;
  flex-direction: column;
  grid-template-columns: none;
  overflow: hidden;
}

/* Companions as a horizontal chip row (not a tall sidebar) */
.cabin-shell--embed .cabin-sidebar {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  width: 100% !important;
  z-index: 1;
  flex: 0 0 auto;
  border-right: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #111827;
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
}

.cabin-shell--embed .cabin-sidebar > .p-4 {
  display: none;
}

.cabin-shell--embed .cabin-sidebar > .p-3.border-t {
  display: none;
}

.cabin-shell--embed #character-list,
.cabin-shell--embed .cabin-sidebar > .flex-1 {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto !important;
  padding: 0.65rem 1.15rem 0.65rem 0.75rem;
  scroll-padding-inline: 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cabin-shell--embed #character-list::after {
  content: '';
  flex: 0 0 0.75rem;
}

.cabin-shell--embed #character-list::-webkit-scrollbar {
  height: 4px;
}
.cabin-shell--embed #character-list::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.35);
  border-radius: 999px;
}

.cabin-shell--embed .char-card {
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  max-width: none;
  align-items: center;
  padding: 0.45rem 0.7rem 0.45rem 0.45rem;
  gap: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cabin-shell--embed .char-card.active {
  border-color: rgba(139, 92, 246, 0.55);
  background: rgba(139, 92, 246, 0.18);
}

.cabin-shell--embed .char-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.cabin-shell--embed .char-card .text-xs.text-violet-glow\/90,
.cabin-shell--embed .char-card .text-xs.text-gray-500 {
  display: none;
}

.cabin-shell--embed .char-card .min-w-0 > :not(:first-child) {
  display: none;
}

.cabin-shell--embed .char-card .font-semibold {
  font-size: 0.8rem;
  white-space: nowrap;
}

.cabin-shell--embed .cabin-sidebar-backdrop {
  display: none !important;
}

.cabin-shell--embed .cabin-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cabin-shell--embed .chat-scroll {
  padding: 0.85rem 1rem;
  flex: 1 1 auto;
  min-height: 0;
}

.cabin-shell--embed .msg-image {
  max-width: min(100%, 280px);
  max-height: 300px;
}

.cabin-shell--embed .chat-scroll .py-12,
.cabin-shell--embed .chat-scroll .py-16 {
  padding-top: 1.25rem !important;
  padding-bottom: 1.25rem !important;
}

.cabin-shell--embed .chat-composer {
  padding: 0.65rem 0.75rem 0.75rem;
  flex: 0 0 auto;
}

.cabin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex: 0 0 auto;
  font-size: 0.75rem;
  color: #9CA3AF;
}

.btn-clear-chat {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #C4B5FD;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
}
.btn-clear-chat:hover {
  border-color: rgba(236, 72, 153, 0.45);
  color: #F472B6;
}

.cabin-shell--embed #btn-sidebar {
  display: none !important;
}

.cabin-shell--embed > #cabin-lock,
.cabin-shell--embed > .cabin-lock,
.cabin-lock {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  text-align: center;
  background: rgba(11, 15, 25, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 100%;
  height: 100%;
  margin: 0;
}

.cabin-shell--embed > #cabin-lock,
.cabin-shell--embed > .cabin-lock {
  grid-row: 1 / -1;
  grid-column: 1 / -1;
}

.cabin-lock[hidden],
.cabin-shell--embed.is-authed > #cabin-lock,
.cabin-shell--embed.is-authed > .cabin-lock {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.cabin-lock-inner {
  max-width: 320px;
  padding: 1.15rem 1.1rem;
  border-radius: 1rem;
  border: 1px solid rgba(139, 92, 246, 0.35);
  background: rgba(21, 28, 44, 0.95);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.cabin-lock-inner h2 {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.4rem;
}

.cabin-lock-inner p {
  font-size: 0.82rem;
  color: #9CA3AF;
  line-height: 1.5;
  margin: 0 0 1rem;
}

.cabin-lock-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.cabin-lock-actions .btn-primary,
.cabin-lock-actions button {
  padding: 0.65rem 1.15rem;
  font-size: 0.875rem;
}

.hero-cabin {
  position: relative;
  width: 100%;
  max-width: 58rem;
  margin-left: auto;
  margin-right: auto;
}

.hero-cabin-glow {
  position: absolute;
  inset: -6% -3%;
  background: radial-gradient(ellipse at 50% 40%, rgba(139, 92, 246, 0.2), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.hero-cabin .cabin-shell--embed {
  position: relative;
  z-index: 1;
}

@media (max-width: 640px) {
  .cabin-shell--embed {
    height: clamp(460px, 68vh, 620px);
    min-height: 440px;
    border-radius: 1rem;
  }

  .cabin-shell--embed > header {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .msg-bubble,
  .msg-bubble-wrap {
    max-width: min(88%, 100%);
  }

  .msg-image {
    max-width: min(100%, 240px);
    max-height: 260px;
  }

  .msg-actions {
    opacity: 0.9;
  }

  .cabin-lock {
    padding: 0.75rem;
    align-items: flex-end;
    padding-bottom: 1rem;
  }

  .cabin-lock-inner {
    max-width: 100%;
    width: 100%;
  }

  .cabin-lock-actions {
    flex-direction: column;
  }

  .cabin-lock-actions button {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .cabin-shell--embed {
    height: clamp(420px, 66vh, 560px);
    min-height: 400px;
  }
}
