/* ============================================
   破茧·归航 — Andie Theme for Bootstrap 5
   Warm Organic Modernism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  /* Brand Colors - Warm & Healing */
  --andie-sage: #8750c8;
  --andie-sage-light: #b39ae0;
  --andie-sage-dark: #6a3aa8;
  --andie-rose: #e08e8e;
  --andie-rose-light: #f5c4c4;
  --andie-rose-dark: #b86b6b;
  --andie-cream: #faf8f5;
  --andie-cream-dark: #f2ede6;
  --andie-sand: #e8dfd3;
  --andie-charcoal: #3d3d3d;
  --andie-soft-blue: #5096dc;
  --brand-violet: #8750c8;
  --brand-blue: #5096dc;
  --brand-grad: linear-gradient(120deg, #8750c8, #5096dc);
  --andie-lavender: #b8a9c9;
  --andie-mint: #9bc4b5;
  
  /* Bootstrap Overrides */
  --bs-primary: var(--andie-sage);
  --bs-primary-rgb: 135, 80, 200;
  --bs-secondary: var(--andie-lavender);
  --bs-secondary-rgb: 184, 169, 201;
  --bs-success: var(--andie-mint);
  --bs-success-rgb: 155, 196, 181;
  --bs-info: var(--andie-soft-blue);
  --bs-info-rgb: 143, 184, 212;
  --bs-warning: #f4c430;
  --bs-warning-rgb: 244, 196, 48;
  --bs-danger: var(--andie-rose-dark);
  --bs-danger-rgb: 184, 107, 107;
  --bs-light: var(--andie-cream);
  --bs-light-rgb: 250, 248, 245;
  --bs-dark: var(--andie-charcoal);
  --bs-dark-rgb: 61, 61, 61;
  
  --bs-body-font-family: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.6;
  --bs-body-color: #4a4a4a;
  --bs-body-bg: var(--andie-cream);
  
  --bs-border-radius: 0.75rem;
  --bs-border-radius-sm: 0.5rem;
  --bs-border-radius-lg: 1rem;
  --bs-border-radius-xl: 1.25rem;
  --bs-border-radius-xxl: 1.5rem;
  
  --bs-box-shadow-sm: 0 2px 4px rgba(61, 61, 61, 0.04);
  --bs-box-shadow: 0 4px 12px rgba(61, 61, 61, 0.06);
  --bs-box-shadow-lg: 0 8px 28px rgba(61, 61, 61, 0.08);
}

/* ============================================
   Base Styles
   ============================================ */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--bs-body-font-family);
  background: var(--andie-cream);
  color: var(--bs-body-color);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--andie-charcoal);
}

/* ============================================
   Layout
   ============================================ */
.app-shell {
  display: flex;
  min-height: calc(100vh - 72px);
}

.app-main {
  flex: 1;
  padding: 1.5rem;
  margin-left: 0;
  min-width: 0;
  overflow-x: hidden;
  transition: margin-left 0.3s ease;
}
body.no-sidebar .app-main {
  padding: 0;
}

@media (min-width: 992px) {
  .app-main {
    margin-left: 260px;
    padding: 2rem;
  }
  body.no-sidebar .app-main {
    margin-left: 0;
    padding: 0;
  }
}

/* ============================================
   Header
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: 72px;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(135, 80, 200, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--andie-charcoal);
}

.brand-link img {
  width: 40px;
  height: 40px;
}

.brand-text strong {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text small {
  display: block;
  font-size: 0.75rem;
  color: var(--andie-sage);
  font-weight: 500;
}

.header-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--andie-charcoal);
  background: rgba(135, 80, 200, 0.08);
  transition: all 0.2s ease;
  text-decoration: none;
}

.header-icon:hover {
  background: rgba(135, 80, 200, 0.15);
  transform: translateY(-1px);
}

.header-icon__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--andie-rose-dark);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem 0.375rem 0.375rem;
  background: white;
  border-radius: 2rem;
  box-shadow: var(--bs-box-shadow-sm);
  text-decoration: none;
  color: var(--andie-charcoal);
  transition: all 0.2s ease;
}

.header-user:hover {
  box-shadow: var(--bs-box-shadow);
  transform: translateY(-1px);
}

.header-user__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--andie-sage), var(--andie-sage-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
}

.header-user__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-user__name {
  font-size: 0.875rem;
  font-weight: 600;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  display: none;
  position: fixed;
  left: 0;
  top: 72px;
  bottom: 0;
  width: 260px;
  background: white;
  border-right: 1px solid rgba(135, 80, 200, 0.1);
  padding: 1.5rem;
  z-index: 1020;
  flex-direction: column;
}

@media (min-width: 992px) {
  .sidebar {
    display: flex;
  }
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  color: #6b6b6b;
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.sidebar__link:hover {
  background: var(--andie-cream-dark);
  color: var(--andie-charcoal);
}

.sidebar__link.is-active {
  background: linear-gradient(135deg, var(--andie-sage), var(--andie-sage-light));
  color: white;
  box-shadow: 0 4px 12px rgba(135, 80, 200, 0.3);
}

.sidebar__icon {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
}

.sidebar-help {
  margin-top: auto;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(135, 80, 200, 0.08), rgba(224, 142, 142, 0.08));
  border-radius: 1rem;
  border: 1px solid rgba(135, 80, 200, 0.1);
}

.sidebar-help__title {
  font-size: 0.8125rem;
  color: #666;
  margin-bottom: 0.375rem;
  font-weight: 500;
}

.sidebar-help__body {
  font-size: 0.75rem;
  color: #888;
}

.sidebar-help__tel {
  color: var(--andie-sage);
  font-weight: 700;
  text-decoration: none;
}

.sidebar__divider {
  height: 1px;
  background: rgba(135, 80, 200, 0.1);
  margin: 0.75rem 0;
}

/* ============================================
   Mobile Nav
   ============================================ */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(135, 80, 200, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 992px) {
  .mobile-nav {
    display: none;
  }
}

.mobile-nav__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0.5rem 0.75rem;
  color: #999;
  font-size: 0.6875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 0.75rem;
}

.mobile-nav__link.is-active {
  color: var(--andie-sage);
  background: rgba(135, 80, 200, 0.08);
}

.mobile-nav__icon {
  font-size: 1.25rem;
}

/* ============================================
   Cards & Components
   ============================================ */
.card {
  border: 1px solid rgba(135, 80, 200, 0.12);
  border-radius: 1rem;
  box-shadow: var(--bs-box-shadow-sm);
  background: white;
  transition: all 0.25s ease;
}

.card:hover {
  box-shadow: var(--bs-box-shadow);
}

.card-body {
  padding: 1.5rem;
}

.andie-card {
  background: white;
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(61, 61, 61, 0.05);
  border: 1px solid rgba(135, 80, 200, 0.08);
}

.andie-card-gradient {
  background: linear-gradient(135deg, #fff 0%, #faf8f5 100%);
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  font-weight: 600;
  border-radius: 0.75rem;
  padding: 0.625rem 1.25rem;
  transition: all 0.2s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(120deg, #7c45bd, #4a86d0);
  box-shadow: 0 4px 14px rgba(135, 80, 200, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(120deg, #6a3aa8, #3a78c0);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(135, 80, 200, 0.34);
}

.btn-rose {
  background: linear-gradient(135deg, var(--andie-rose-dark), var(--andie-rose));
  color: white;
  box-shadow: 0 4px 14px rgba(184, 107, 107, 0.3);
}

.btn-rose:hover {
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(184, 107, 107, 0.35);
}

.btn-outline-primary {
  border: 1.5px solid var(--andie-sage);
  color: var(--andie-sage);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--andie-sage);
  color: white;
}

.btn-light {
  background: var(--andie-cream-dark);
  color: var(--andie-charcoal);
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: 0.875rem;
}

.btn-sm {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: 0.625rem;
}

/* ============================================
   Form Controls
   ============================================ */
.form-control, .form-select {
  border: 1.5px solid rgba(135, 80, 200, 0.2);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  background: white;
  transition: all 0.2s ease;
}

@media (max-width: 991.98px) {
  input,
  textarea,
  select,
  .form-control,
  .form-select {
    font-size: 16px !important;
  }
}

.form-control:focus, .form-select:focus {
  border-color: var(--andie-sage);
  box-shadow: 0 0 0 4px rgba(135, 80, 200, 0.1);
  background: white;
}

.form-control::placeholder {
  color: #aaa;
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--andie-charcoal);
  margin-bottom: 0.5rem;
}

.form-check-input:checked {
  background-color: var(--andie-sage);
  border-color: var(--andie-sage);
}

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
  font-weight: 600;
  padding: 0.5em 0.85em;
  border-radius: 0.5rem;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  border-radius: 2rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: rgba(135, 80, 200, 0.1);
  color: var(--andie-sage-dark);
}

/* ============================================
   Animations
   ============================================ */
.fade-in-up {
  animation: fadeInUp 0.5s ease-out both;
}

.fade-in-up-delay-1 { animation-delay: 0.08s; }
.fade-in-up-delay-2 { animation-delay: 0.16s; }
.fade-in-up-delay-3 { animation-delay: 0.24s; }
.fade-in-up-delay-4 { animation-delay: 0.32s; }

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

.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--bs-box-shadow-lg);
}

/* ============================================
   Utilities
   ============================================ */
.text-sage { color: var(--andie-sage) !important; }
.text-rose { color: var(--andie-rose-dark) !important; }
.text-muted-custom { color: #888 !important; }

.bg-sage-soft { background: rgba(135, 80, 200, 0.08) !important; }
.bg-rose-soft { background: rgba(224, 142, 142, 0.12) !important; }
.bg-cream { background: var(--andie-cream) !important; }

.rounded-2xl { border-radius: 1rem !important; }
.rounded-3xl { border-radius: 1.25rem !important; }
.rounded-4xl { border-radius: 1.5rem !important; }

.shadow-soft { box-shadow: 0 4px 20px rgba(61, 61, 61, 0.05) !important; }
.shadow-soft-lg { box-shadow: 0 8px 32px rgba(61, 61, 61, 0.08) !important; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #888;
}

.empty-state__icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--andie-charcoal);
  margin-bottom: 0.25rem;
}

/* ============================================
   Toast / Alerts
   ============================================ */
.toast-andie {
  position: fixed;
  top: 88px;
  right: 1.5rem;
  z-index: 1055;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background: white;
  box-shadow: 0 8px 32px rgba(61, 61, 61, 0.12);
  border: 1px solid rgba(135, 80, 200, 0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 400px;
  animation: slideInRight 0.4s ease;
}

.toast-andie--success {
  border-left: 4px solid var(--andie-mint);
}

.toast-andie--error {
  border-left: 4px solid var(--andie-rose-dark);
}

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

/* ============================================
   Page-specific helpers
   ============================================ */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.page-header p {
  color: #888;
  font-size: 0.9375rem;
  margin-bottom: 0;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--andie-charcoal);
}

.list-group-andie {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.list-group-andie .list-group-item {
  border: 1px solid rgba(135, 80, 200, 0.1);
  border-radius: 0.875rem;
  padding: 1rem 1.25rem;
  background: white;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.list-group-andie .list-group-item:hover {
  border-color: rgba(135, 80, 200, 0.2);
  box-shadow: var(--bs-box-shadow-sm);
  transform: translateY(-1px);
}

/* Bottom padding for mobile nav */
.pb-mobile {
  padding-bottom: 80px;
}

@media (min-width: 992px) {
  .pb-mobile {
    padding-bottom: 0;
  }
}

/* ============================================
   Chat Styles (Bootstrap 5 Warm Theme)
   ============================================ */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: fadeInUp 0.3s ease-out;
}

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

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

.message__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.message--user .message__avatar {
  background: linear-gradient(135deg, var(--andie-sage), var(--andie-sage-light));
  color: white;
}

.message--assistant .message__avatar {
  background: linear-gradient(135deg, var(--andie-rose-light), var(--andie-rose));
  color: white;
}

.message__content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.message__bubble {
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.6;
  font-size: 0.9375rem;
}

.message--user .message__bubble {
  background: linear-gradient(135deg, var(--andie-sage), var(--andie-sage-light));
  color: white;
  border-bottom-right-radius: 0.25rem;
  box-shadow: 0 4px 12px rgba(135, 80, 200, 0.25);
}

.message--assistant .message__bubble {
  background: white;
  color: var(--andie-charcoal);
  border: 1px solid rgba(135, 80, 200, 0.12);
  border-bottom-left-radius: 0.25rem;
  box-shadow: var(--bs-box-shadow-sm);
}

.message__meta {
  font-size: 0.75rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.message--user .message__meta {
  justify-content: flex-end;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.875rem 1.125rem;
  background: white;
  border-radius: 1rem;
  border: 1px solid rgba(135, 80, 200, 0.12);
  width: fit-content;
  box-shadow: var(--bs-box-shadow-sm);
}

.typing-indicator__face img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block; box-shadow: 0 2px 6px rgba(135, 80, 200, 0.2); }
.typing-indicator__dots { display: inline-flex; gap: 0.3rem; align-items: center; }
.typing-indicator__dots span {
  width: 7px;
  height: 7px;
  background: var(--andie-sage);
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}
.typing-indicator__dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator__dots span:nth-child(3) { animation-delay: 0.4s; }
.typing-indicator__hint { font-size: 0.78rem; color: var(--andie-sage-dark); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .typing-indicator__face img { animation: typingFace 2.4s ease-in-out infinite; }
  @keyframes typingFace { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
}

.chat-welcome__face { display: flex; justify-content: center; margin-bottom: 0.75rem; }
.chat-welcome__face img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; box-shadow: 0 8px 22px rgba(135, 80, 200, 0.25); background: radial-gradient(120% 120% at 50% 25%, #f3eefc, #e7eefb); }
@media (prefers-reduced-motion: no-preference) {
  .chat-welcome__face img { animation: chatFaceBreathe 6s ease-in-out infinite; }
  @keyframes chatFaceBreathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
}

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
}

/* ============================================
   Chat Layout v2
   ============================================ */

.chat-page {
  display: flex;
  height: calc(100vh - 72px);
  overflow: hidden;
  margin: -1.5rem;
}

@media (min-width: 992px) {
  .chat-page {
    margin: -2rem;
  }
}

.chat-sidebar {
  display: flex;
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid rgba(135, 80, 200, 0.1);
  flex-direction: column;
}

.chat-sidebar__header {
  padding: 1rem;
  border-bottom: 1px solid rgba(135, 80, 200, 0.08);
}

.chat-sidebar__search {
  padding: 0.75rem 1rem;
}

.chat-sidebar__search .form-control {
  background: var(--andie-cream);
  border-color: rgba(135, 80, 200, 0.12);
}

.chat-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.875rem;
  color: #555;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.conversation-item:hover {
  background: rgba(135, 80, 200, 0.05);
  border-color: rgba(135, 80, 200, 0.08);
}

.conversation-item.is-active {
  background: linear-gradient(135deg, rgba(135, 80, 200,0.12), rgba(135, 80, 200,0.05));
  border-color: rgba(135, 80, 200, 0.15);
  color: var(--andie-charcoal);
}

.conversation-item__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(135, 80, 200, 0.08);
  flex-shrink: 0;
}

.conversation-item.is-active .conversation-item__avatar {
  background: rgba(135, 80, 200, 0.15);
}

.conversation-item__content {
  flex: 1;
  min-width: 0;
}

.conversation-item__title {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.conversation-item__meta {
  font-size: 0.75rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid rgba(135, 80, 200, 0.08);
  background: linear-gradient(90deg, #fff, #faf8f5);
}

.chat-header__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header__scene {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  background: rgba(135, 80, 200, 0.1);
  color: var(--andie-sage-dark);
  border-radius: 0.5rem;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(180deg, #faf8f5 0%, #fff 100%);
}

.chat-footer {
  border-top: 1px solid rgba(135, 80, 200, 0.08);
  background: #fff;
  padding: 0.75rem 1.25rem 1rem;
}

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.chat-welcome {
  text-align: center;
  max-width: 420px;
  margin: auto;
  color: #666;
}

.chat-welcome__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, rgba(135, 80, 200,0.1), rgba(224,142,142,0.1));
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
}

.chat-welcome__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--andie-charcoal);
  margin-bottom: 0.5rem;
}

.chat-welcome__text {
  font-size: 0.9375rem;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

/* Composer */
.chat-composer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-composer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.chat-composer__input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.chat-composer__textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 160px;
  padding: 0.75rem 1rem;
  line-height: 1.6;
}

.chat-composer__submit {
  height: 48px;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.875rem;
  padding: 0;
}

/* Mobile: use full height minus mobile nav */
@media (max-width: 991.98px) {
  .chat-page {
    flex-direction: column;
    height: calc(100vh - 72px - 64px);
    margin: -1.5rem;
  }
  .chat-sidebar {
    display: none;
    width: 100%;
    max-height: 170px;
    border-right: none;
    border-bottom: 1px solid rgba(135, 80, 200, 0.1);
  }
  .chat-sidebar.is-open {
    display: flex;
  }
  .chat-sidebar__header,
  .chat-sidebar__search {
    padding: 0.5rem 1rem;
  }
  .chat-sidebar__list {
    padding-bottom: 0.5rem;
  }
  .chat-main {
    width: 100%;
    min-height: 0;
  }
}

/* ============================================
   Mobile Enhancements
   ============================================ */
@media (max-width: 991.98px) {
  input, textarea, select { font-size: 16px !important; }
}
.ios-keyboard-open .mobile-nav {
  transform: translateY(100%);
  transition: transform 0.2s ease;
}

/* ============================================
   Accessibility: 尊重用户的减少动画偏好
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   Page Progress Bar (driven by app.js)
   ============================================ */
.page-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--andie-sage), var(--andie-lavender));
  width: 0%;
  z-index: 99999;
  transition: width 0.2s ease;
  pointer-events: none;
}

/* ============================================
   Global Back-to-Top (driven by app.js)
   ============================================ */
.global-back-to-top {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 24px;
  width: 48px;
  height: 48px;
  display: none;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.1rem;
}
.global-back-to-top.is-visible {
  display: flex;
}

/* ============================================
   Home 仪表盘页面组件
   ============================================ */
.caption-xs { font-size: 0.6875rem; }
.icon-emoji { font-size: 1.25rem; line-height: 1; }
.text-sage-link {
  color: var(--andie-sage);
  text-decoration: none;
}
.text-sage-link:hover { color: var(--andie-sage-dark); }

/* 签到按钮 / 已签到提示 */
.home-checkin-btn {
  width: 64px;
  height: 64px;
  border-radius: 1rem;
  gap: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.home-checkin-btn__icon { font-size: 1.25rem; }
.home-checkin-btn__bonus { font-size: 0.6875rem; }
.home-checkin-done {
  width: 64px;
  height: 64px;
  border-radius: 1rem;
  gap: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(16, 185, 129, 0.1);
  color: var(--bs-success);
}
.home-checkin-done__icon { font-size: 1rem; }
.home-checkin-done__label { font-size: 0.6875rem; font-weight: 600; }

/* 等级卡（动态色通过 --level-color 传入） */
.home-level-card {
  border-color: var(--level-color, var(--andie-sage));
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--level-color, var(--andie-sage)) 8%, white),
    color-mix(in srgb, var(--level-color, var(--andie-sage)) 3%, white));
}
.home-level-card__name { color: var(--level-color, var(--andie-sage)); }

/* 周签到日历 */
.home-week-day {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-radius: 0.75rem;
}
.home-week-day--today { background: rgba(135, 80, 200, 0.1); }
.home-week-day__dot {
  width: 5px;
  height: 5px;
  background: var(--bs-success);
  border-radius: 50%;
  margin: 4px auto 0;
}

/* 快捷操作横排 */
.home-quick-actions {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 0.75rem;
}
.home-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 64px;
  height: 72px;
  border-radius: 1rem;
  gap: 3px;
  border: 1px solid rgba(135, 80, 200, 0.15);
}
.home-quick-action--primary {
  min-width: 88px;
  border: none;
}
.home-quick-action__icon { font-size: 1.25rem; line-height: 1; }
.home-quick-action__label { font-size: 0.6875rem; }

/* ============================================
   共享组件（growth / profile / 其他仪表盘）
   ============================================ */
/* 用户头像圆形（通过 --avatar-size 调节） */
.user-avatar {
  --avatar-size: 64px;
  --avatar-font-size: 1.5rem;
  width: var(--avatar-size);
  height: var(--avatar-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--andie-sage), var(--andie-sage-light));
  color: #fff;
  font-weight: 700;
  font-size: var(--avatar-font-size);
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
}
.user-avatar--lg { --avatar-size: 72px; --avatar-font-size: 1.75rem; }
.user-avatar--xl { --avatar-size: 96px; --avatar-font-size: 2rem; }
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* 等级徽章 */
.level-pill {
  background: white;
  color: var(--andie-sage-dark);
  font-weight: 600;
}
.level-pill--soft {
  background: rgba(135, 80, 200, 0.1);
  color: var(--andie-sage-dark);
}

/* 安蝶记忆卡片（growth / profile 复用） */
.memory-summary-card {
  background: linear-gradient(135deg, rgba(135, 80, 200, 0.08), rgba(184, 169, 201, 0.08));
}

/* 成长档案头 / 渐变背景卡片 */
.growth-hero {
  background: linear-gradient(135deg, rgba(135, 80, 200, 0.12), rgba(184, 169, 201, 0.1));
}
.growth-progress-track {
  background: rgba(255, 255, 255, 0.5);
  min-width: 0;
  height: 8px;
}
.growth-progress-fill { background: var(--andie-sage); }

/* 水平横滚 chip 列表（成就 / 证书 等） */
.scroll-chip-list {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 0;
}
@media (min-width: 768px) {
  .scroll-chip-list--md-stack {
    flex-direction: column;
    overflow-x: visible;
    padding-bottom: 0;
  }
}
.scroll-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  background: rgba(135, 80, 200, 0.05);
  flex: 0 0 auto;
  width: 200px;
  text-decoration: none;
  color: inherit;
}
.scroll-chip:hover {
  background: rgba(135, 80, 200, 0.1);
  color: inherit;
}

/* 时间线 */
.growth-timeline {
  position: relative;
  padding-left: 1rem;
}
.growth-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(135, 80, 200, 0.15);
}
.growth-timeline__item {
  position: relative;
  padding-bottom: 0.75rem;
}
.growth-timeline__dot {
  position: absolute;
  left: -3px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--andie-sage);
  border: 2px solid white;
}
.growth-timeline__body { margin-left: 1rem; }
@media (max-width: 767.98px) {
  .growth-timeline__title { font-size: 0.8rem; }
  .growth-timeline__date  { font-size: 0.75rem; }
}

/* 积分明细行 */
.point-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.75rem;
  background: rgba(135, 80, 200, 0.05);
}
.point-row__reason {
  max-width: 70%;
}

/* Profile 快捷入口卡片（icon + label，等高等宽） */
.profile-quicklink {
  padding: 0.75rem 0;
  text-align: center;
  text-decoration: none;
  color: inherit;
}
.profile-quicklink__icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

/* Profile 编辑按钮的次级边框 */
.btn-profile-edit {
  border: 1px solid rgba(135, 80, 200, 0.15);
}

/* 最近对话 / 心情列表 */
.home-recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.home-recent-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  color: inherit;
  text-decoration: none;
  transition: all 0.15s ease;
}
.home-recent-item:hover {
  background: rgba(135, 80, 200, 0.06);
  color: inherit;
}
.home-recent-item__icon { font-size: 1.25rem; line-height: 1; width: 28px; text-align: center; }
.home-recent-item__main { flex: 1; min-width: 0; }

/* ============================================
   Form Submission State (driven by form.js)
   ============================================ */
form.is-submitting .btn-text { display: none; }
form.is-submitting .btn-spinner { display: inline !important; }
form.is-submitting button[type="submit"],
form.is-submitting button:not([type]),
form.is-submitting input[type="submit"] {
  opacity: 0.85;
  cursor: not-allowed;
}

.form-error-summary {
  display: block;
  margin-top: 0.5rem;
  padding: 0.625rem 0.875rem;
  background: rgba(184, 107, 107, 0.08);
  border-left: 3px solid var(--andie-rose-dark);
  border-radius: 0.5rem;
  color: var(--andie-rose-dark);
  font-size: 0.875rem;
}
