/* Beyond Mutual Fund — dark, gradient-accent UI */

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

:root,
[data-theme="dark"] {
  --bg-deep: #050508;
  --bg-elevated: #0c0c12;
  --bg-card: #12121a;
  --bg-card-hover: #181824;
  --text: #f4f4f8;
  --text-muted: #9898a8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent-violet: #a855f7;
  --accent-fuchsia: #e879f9;
  --accent-cyan: #22d3ee;
  --gradient-brand: linear-gradient(135deg, #a855f7 0%, #e879f9 45%, #22d3ee 100%);
  --gradient-subtle: linear-gradient(180deg, rgba(168, 85, 247, 0.12) 0%, transparent 55%);
  --success: #4ade80;
  --shadow-soft: 0 24px 80px rgba(0, 0, 0, 0.55);
  --sidebar-bg: rgba(8, 8, 14, 0.96);
  --topbar-scrim: rgba(5, 5, 8, 0.92);
  --page-glow-purple: rgba(168, 85, 247, 0.22);
  --page-glow-cyan: rgba(34, 211, 238, 0.08);
  --page-glow-pink: rgba(232, 121, 249, 0.06);
  --carousel-arrow-bg: rgba(14, 14, 22, 0.88);
  --auth-login-bg: #f4f4f8;
  --auth-login-text: #0a0a0f;
  --assistant-bubble-bg: rgba(255, 255, 255, 0.04);
  --nav-hover-bg: rgba(255, 255, 255, 0.05);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-display: "Outfit", var(--font-sans);
}

[data-theme="light"] {
  --bg-deep: #f7f7fb;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0f5;
  --text: #141418;
  --text-muted: #5c5c66;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --gradient-subtle: linear-gradient(180deg, rgba(168, 85, 247, 0.08) 0%, transparent 55%);
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.1);
  --sidebar-bg: rgba(255, 255, 255, 0.96);
  --topbar-scrim: rgba(247, 247, 251, 0.92);
  --page-glow-purple: rgba(168, 85, 247, 0.12);
  --page-glow-cyan: rgba(34, 211, 238, 0.1);
  --page-glow-pink: rgba(232, 121, 249, 0.08);
  --carousel-arrow-bg: rgba(255, 255, 255, 0.95);
  --auth-login-bg: #141418;
  --auth-login-text: #f4f4f8;
  --assistant-bubble-bg: rgba(0, 0, 0, 0.04);
  --nav-hover-bg: rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
  -webkit-tap-highlight-color: rgba(168, 85, 247, 0.18);
}

body.nav-open {
  overflow: hidden;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 100% 60% at 50% -30%, var(--page-glow-purple), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 20%, var(--page-glow-cyan), transparent 45%),
    radial-gradient(ellipse 60% 40% at 0% 60%, var(--page-glow-pink), transparent 50%),
    var(--bg-deep);
  transition: background 0.25s ease;
}

/* App shell — left sidebar + main (row by default; never stack until narrow breakpoint below) */
.app-shell {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 50;
  flex: 0 0 16rem;
  width: 16rem;
  max-width: 100%;
  height: 100vh;
  border-right: 1px solid var(--border-strong);
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: width 0.22s ease, flex-basis 0.22s ease, background 0.25s ease, border-color 0.25s ease;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 1.35rem 1rem 1.5rem;
  min-height: 100%;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}

.sidebar .logo {
  flex-wrap: nowrap;
}

.logo-text {
  line-height: 1.25;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.sidebar-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-toggle-icon {
  width: 1.1rem;
  height: 1.1rem;
  transition: transform 0.22s ease;
}

.sidebar--collapsed {
  flex: 0 0 4.5rem;
  width: 4.5rem;
}

.sidebar--collapsed .sidebar-inner {
  padding: 1.1rem 0.5rem 1.25rem;
  align-items: center;
}

.sidebar--collapsed .sidebar-top {
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.sidebar--collapsed .logo-text,
.sidebar--collapsed .tagline,
.sidebar--collapsed .nav-link-label {
  display: none;
}

.sidebar--collapsed .logo {
  justify-content: center;
}

.sidebar--collapsed .nav-link-short {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sidebar--collapsed .nav--sidebar {
  width: 100%;
  align-items: center;
}

.sidebar--collapsed .nav--sidebar .nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin: 0 auto;
  border-radius: var(--radius-md);
}

.sidebar--collapsed .nav--sidebar .nav-cta {
  margin-top: 0.4rem;
}

.sidebar--collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.nav-link-short {
  display: none;
}

.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 0.75rem 0;
}

.app-body > main,
.app-body > .guide-main,
.app-body > .landing-main {
  flex: 1 0 auto;
}

/* Top bar — Log in / Sign up (top-right) */
.app-topbar {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  padding: max(0.65rem, env(safe-area-inset-top, 0px)) 0 0.35rem;
  background: linear-gradient(180deg, var(--topbar-scrim) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background 0.25s ease;
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.menu-toggle {
  display: none;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(168, 85, 247, 0.45);
}

.menu-toggle-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.menu-toggle-icon--close {
  display: none;
}

body.nav-open .menu-toggle-icon--open {
  display: none;
}

body.nav-open .menu-toggle-icon--close {
  display: block;
}

.app-topbar-brand {
  display: none;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.app-topbar-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backdrop {
  display: none;
}

.app-topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

/* Light / dark theme switch (sun & moon) */
.theme-switch {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-switch-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-switch-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 3.65rem;
  height: 2rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.theme-switch-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
  z-index: 1;
  color: var(--text-muted);
  pointer-events: none;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.65rem;
  height: calc(100% - 4px);
  border-radius: 999px;
  background: var(--gradient-brand);
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.35);
  transition: transform 0.22s ease;
  pointer-events: none;
}

.theme-switch-input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(1.75rem);
}

.theme-switch-input:checked + .theme-switch-track .theme-switch-icon--sun {
  color: #0a0a0f;
}

.theme-switch-input:not(:checked) + .theme-switch-track .theme-switch-icon--moon {
  color: #e9d5ff;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s, filter 0.2s;
}

.auth-btn--login {
  border: none;
  color: var(--auth-login-text);
  background: var(--auth-login-bg);
}

.auth-btn--login:hover {
  filter: brightness(1.06);
}

.auth-btn--signup {
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.auth-btn--signup:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.auth-btn-extra {
  display: inline;
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-modal[hidden] {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top, 0px)) 1.25rem max(1rem, env(safe-area-inset-bottom, 0px));
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.auth-modal-panel {
  position: relative;
  width: 100%;
  max-width: 22rem;
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.auth-modal-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.auth-modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.auth-modal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  padding-right: 1.5rem;
}

.auth-modal-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.auth-social {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.auth-social[hidden],
.auth-social-btn[hidden] {
  display: none !important;
}

.auth-social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: filter 0.2s, background 0.2s, border-color 0.2s;
}

.auth-social-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.auth-social-btn--google {
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #1f1f1f;
  background: #fff;
}

.auth-social-btn--google:hover {
  filter: brightness(0.97);
  background: #f8f8f8;
}

.auth-social-btn--facebook {
  border: 1px solid #1877f2;
  color: #fff;
  background: #1877f2;
}

.auth-social-btn--facebook:hover {
  filter: brightness(1.06);
  background: #166fe5;
}

.auth-social-btn--facebook .auth-social-icon {
  color: #fff;
}

.auth-form-error {
  font-size: 0.8125rem;
  color: #f87171;
  margin: 0.65rem 0 0;
  text-align: center;
}

.auth-modal-foot {
  margin-top: 1.1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-link-btn {
  border: none;
  padding: 0;
  background: none;
  color: var(--accent-fuchsia);
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-link-btn:hover {
  color: var(--accent-cyan);
}

.auth-guest,
.auth-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-guest[hidden],
.auth-user[hidden] {
  display: none !important;
}

.auth-user {
  max-width: min(100%, 14rem);
}

.auth-user-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-btn--logout {
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: transparent;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
}

.auth-btn--logout:hover {
  background: rgba(255, 255, 255, 0.06);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: lowercase;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.auth-field-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md, 0.5rem);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.auth-input:focus {
  outline: 2px solid var(--accent-fuchsia);
  outline-offset: 1px;
}

.auth-submit-btn {
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-fuchsia), var(--accent-cyan));
  cursor: pointer;
}

.auth-submit-btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 480px) {
  .auth-actions {
    gap: 0.35rem;
  }

  .auth-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8125rem;
  }

  .auth-btn--signup {
    padding-inline: 0.65rem;
  }
}

.logo {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--gradient-brand);
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.35);
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.4;
  max-width: 13rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav--sidebar {
  flex-direction: column;
  align-items: stretch;
  align-self: stretch;
  gap: 0.3rem;
  margin-top: 1.15rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.nav--sidebar .nav-link {
  display: block;
  width: 100%;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  text-align: left;
}

.nav--sidebar .nav-cta {
  margin-left: 0;
  margin-top: 0.4rem;
  text-align: left;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.nav-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.nav-cta {
  margin-left: 0.35rem;
}

/* Sidebar: inactive links muted; active link uses brand gradient (Home, Featured Funds, Ask AI) */
.nav--sidebar .nav-link:not(.active) {
  color: var(--text-muted);
  background: transparent;
  box-shadow: none;
}

.nav--sidebar .nav-link:not(.active):hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav--sidebar .nav-link.active {
  color: #0a0a0f !important;
  background: var(--gradient-brand) !important;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(168, 85, 247, 0.35);
}

.nav--sidebar .nav-link.active:hover {
  filter: brightness(1.08);
  color: #0a0a0f !important;
}

/* Main — flex column: chat region fills space above carousel; carousel pinned to bottom row */
.main {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
}

/* min-width:0 so grid/flex ancestors don’t expand to full carousel min-content width (breaks horizontal scroll) */
.main > .section-carousel {
  flex-shrink: 0;
  min-width: 0;
  width: 100%;
}

/* Vertically center chat in the band above the carousel; scroll inside this band when the thread is long */
.main-chat-region {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Full-height chat: hides carousel/footer, messages fill main area */
.main--chat-active {
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

.main--chat-active .section-carousel,
.main--chat-active + .footer {
  display: none;
}

.main--chat-active .main-chat-region {
  flex: 1;
  justify-content: stretch;
  overflow: hidden;
}

.main--chat-active .chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 0.35rem;
}

.main--chat-active .chat-section-head {
  flex-shrink: 0;
  padding: 0 1rem;
  margin-bottom: 0.35rem;
}

.main--chat-active .chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-height: 0;
  padding: 0 1rem 0.75rem;
  align-items: stretch;
  align-self: stretch;
}

.main--chat-active .chat-promo-pill {
  display: none;
}

.main--chat-active .chat-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
  display: flex;
}

.main--chat-active .chat-form {
  flex-shrink: 0;
}

.main--chat-active .message {
  max-width: min(90%, 42rem);
}

/* Sections */
.section {
  padding-top: clamp(1rem, 2.2vw, 1.5rem);
}

.section-carousel .section-head {
  margin-bottom: 0.75rem;
  text-align: left;
}

.section-head {
  margin-bottom: 0.85rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Carousels — arrows overlay track edges, auto-hidden when not scrollable */
.carousel {
  margin-bottom: 1.25rem;
  min-width: 0;
  max-width: 100%;
}

.carousel-viewport {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.carousel-prev,
.carousel-next {
  position: absolute;
  top: 50%;
  z-index: 4;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--carousel-arrow-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    transform 0.2s ease;
}

.carousel-prev {
  left: 0.35rem;
}

.carousel-next {
  right: 0.35rem;
}

.carousel.carousel--can-prev .carousel-prev {
  opacity: 0.88;
  pointer-events: auto;
}

.carousel.carousel--can-next .carousel-next {
  opacity: 0.88;
  pointer-events: auto;
}

[data-theme="light"] .carousel-prev,
[data-theme="light"] .carousel-next {
  border-color: rgba(0, 0, 0, 0.2);
  color: #141418;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
}

.carousel:hover.carousel--can-prev .carousel-prev,
.carousel-prev:hover,
.carousel-prev:focus-visible {
  opacity: 1;
}

.carousel:hover.carousel--can-next .carousel-next,
.carousel-next:hover,
.carousel-next:focus-visible {
  opacity: 1;
}

.carousel-prev:hover,
.carousel-next:hover {
  background: rgba(24, 24, 36, 0.95);
  border-color: rgba(168, 85, 247, 0.4);
  color: var(--accent-fuchsia);
}

.carousel-track {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.65rem 0.25rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
}

.carousel-track::-webkit-scrollbar {
  height: 5px;
}

.carousel-track::-webkit-scrollbar-track {
  background: transparent;
}

.carousel-track::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

.carousel-status {
  flex: 1 0 100%;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 1.5rem;
}

.carousel-status--error {
  color: #f87171;
}

.card-featured .card-title {
  font-size: 1.02rem;
  min-height: 2.75rem;
  line-height: 1.35;
}

.card {
  flex: 0 0 236px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  scroll-snap-align: start;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: rgba(168, 85, 247, 0.25);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(168, 85, 247, 0.08);
    transform: translateY(-2px);
  }
}

.card-returns {
  border-color: rgba(74, 222, 128, 0.2);
  background: linear-gradient(165deg, rgba(74, 222, 128, 0.06) 0%, var(--bg-card) 45%);
}

.card-returns:hover {
  border-color: rgba(74, 222, 128, 0.35);
}

.card-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.18);
  color: #e9d5ff;
  margin-bottom: 0.85rem;
  letter-spacing: 0.04em;
}

.card-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.45rem;
  line-height: 1.35;
}

.card-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.return-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 0.45rem;
  letter-spacing: -0.02em;
}

/* Chat — compact light composer (empty thread by default) */
.chat-section {
  margin-top: 0;
  padding-top: clamp(0.5rem, 1.5vw, 0.85rem);
}

.chat-section-head {
  margin-bottom: 0.5rem;
  text-align: center;
}

.chat-section-head .section-title {
  margin-bottom: 0;
}

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

.chat-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  max-width: min(56rem, 100%);
  margin: 0 auto;
  background: transparent;
  border: none;
  box-shadow: none;
  min-height: 0;
}

.chat-promo-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.28rem 0.75rem 0.28rem 0.28rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.96);
  font-size: 0.78rem;
  color: #5c5c66;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.5) inset;
}

.chat-promo-badge {
  display: inline-block;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #c026d3);
}

.chat-promo-text {
  color: #25252c;
  font-weight: 500;
}

.chat-messages {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  max-height: min(52vh, 360px);
  overflow-y: auto;
}

.chat-messages--empty {
  display: none;
}

.chat-container--has-thread .chat-messages {
  align-self: stretch;
}

.chat-form {
  width: 100%;
}

.chat-composer-card {
  width: 100%;
  border-radius: 22px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  background: #f3f3f5;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.22),
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  overflow: hidden;
}

.chat-input {
  display: block;
  width: 100%;
  min-height: 4.7rem;
  max-height: 20rem;
  padding: 1.1rem 1rem 0.7rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: #141418;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
  -webkit-appearance: none;
  appearance: none;
}

.chat-input::placeholder {
  color: #8b8b96;
}

.chat-input:focus {
  outline: none;
}

.chat-composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.3rem 0.45rem 0.45rem;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: #ebecef;
}

.chat-toolbar-left,
.chat-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-tool-btn[hidden] {
  display: none;
}

.chat-tool-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #3f3f48;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.chat-tool-btn:hover:not(:disabled) {
  background: #f8f8fa;
  color: #1a1a22;
}

.chat-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-tool-btn--ghost {
  background: transparent;
  box-shadow: none;
  color: #6b6b76;
}

.chat-tool-btn--ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

.chat-tool-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.chat-send-fab {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.chat-send-fab:hover:not(:disabled) {
  filter: brightness(1.06);
  color: #fff;
}

.chat-tool-btn.chat-send-fab:disabled {
  background: #c4c4cc;
  box-shadow: none;
  opacity: 1;
  color: #fff;
}

.message {
  display: flex;
  max-width: min(85%, 34rem);
}

.message-user {
  align-self: flex-end;
}

.message-assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  font-size: 0.9375rem;
  line-height: 1.55;
  overflow-x: auto;
  max-width: 100%;
}

.message-user .message-bubble {
  background: var(--gradient-brand);
  color: #0a0a0f;
  font-weight: 500;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 28px rgba(168, 85, 247, 0.35);
}

.message-assistant .message-bubble {
  background: var(--assistant-bubble-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  color: var(--text);
}

.message-assistant .message-bubble strong {
  color: var(--accent-fuchsia);
}

.message-bubble.loading {
  color: var(--text-muted);
  font-style: italic;
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.875rem;
}

.message-bubble th,
.message-bubble td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.message-bubble th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.message-bubble ul,
.message-bubble ol {
  margin: 0.5rem 0;
  padding-left: 1.35rem;
}

.message-bubble p {
  margin: 0.5rem 0;
}

.message-bubble p:first-child {
  margin-top: 0;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.fund-list {
  margin: 0.5rem 0 0 1rem;
  padding: 0;
}

.fund-list li {
  margin-bottom: 0.3rem;
}

/* Footer — bottom of viewport when content is short; after content when long */
.footer {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.25rem;
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.85rem clamp(0.75rem, 2.5vw, 1.25rem) calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--bg);
  width: 100%;
}

.footer a,
.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  margin: 0 0.85rem;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--accent-fuchsia);
}

.svg-stroke-2 {
  stroke-width: 2;
}

/* Phone + tablet (iPhone, Android, iPad): off-canvas drawer, full-width content */
@media (max-width: 1023px) {
  .app-body {
    padding: 0 0.7rem 0;
  }

  .app-topbar {
    z-index: 110;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .app-topbar-brand {
    display: inline-flex;
  }

  .app-topbar-inner {
    justify-content: flex-start;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .sidebar,
  .sidebar.sidebar--collapsed {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    flex: none;
    width: min(20rem, 86vw);
    max-width: 20rem;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-right: 1px solid var(--border-strong);
    transform: translateX(-110%);
    transition: transform 0.22s ease;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .sidebar.sidebar--open,
  .sidebar.sidebar--collapsed.sidebar--open {
    transform: translateX(0);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.4);
  }

  .sidebar.sidebar--collapsed .sidebar-inner {
    padding: 1.35rem 1rem 1.5rem;
    align-items: stretch;
  }

  .sidebar.sidebar--collapsed .sidebar-top {
    flex-direction: row;
    align-items: flex-start;
    width: auto;
  }

  .sidebar.sidebar--collapsed .logo {
    justify-content: flex-start;
  }

  .sidebar.sidebar--collapsed .logo-text,
  .sidebar.sidebar--collapsed .tagline,
  .sidebar.sidebar--collapsed .nav-link-label,
  .sidebar.sidebar--collapsed .nav-section-label {
    display: unset;
  }

  .sidebar.sidebar--collapsed .nav--guides {
    display: flex;
  }

  .sidebar.sidebar--collapsed .nav-link-short {
    display: none;
  }

  .sidebar.sidebar--collapsed .nav--sidebar {
    width: auto;
    align-items: stretch;
  }

  .sidebar.sidebar--collapsed .nav--sidebar .nav-link {
    display: block;
    width: 100%;
    height: auto;
    padding: 0.7rem 0.85rem;
    margin: 0;
    border-radius: var(--radius-md);
    text-align: left;
  }

  .nav--sidebar .nav-link {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }

  .chat-tool-btn {
    width: 2.75rem;
    height: 2.75rem;
  }

  .auth-btn-extra {
    display: none;
  }

  .auth-user {
    max-width: min(100%, 9.5rem);
  }

  .message {
    max-width: min(94%, 42rem);
  }

  .message-bubble table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 767px) {
  .app-body {
    padding: 0 0.5rem 0;
  }

  .app-topbar-name {
    max-width: 9.5rem;
  }

  .theme-switch-track {
    width: 3.25rem;
    height: 1.85rem;
    padding: 0 0.3rem;
  }

  .theme-switch-thumb {
    width: 1.45rem;
  }

  .theme-switch-input:checked + .theme-switch-track .theme-switch-thumb {
    transform: translateX(1.5rem);
  }

  .auth-modal {
    align-items: flex-end;
    padding: 0;
  }

  .auth-modal-panel {
    max-width: none;
    width: 100%;
    max-height: min(92dvh, 100%);
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 1.5rem 1.15rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }

  .chat-input {
    min-height: 3.4rem;
    padding: 0.9rem 0.85rem 0.55rem;
  }

  .carousel-prev,
  .carousel-next {
    width: 2.5rem;
    height: 2.5rem;
  }

  .footer a,
  .footer-link {
    margin: 0.15rem 0.55rem;
  }
}

@media (max-width: 430px) {
  .app-topbar-name {
    display: none;
  }

  .auth-btn {
    padding: 0.4rem 0.7rem;
  }
}
