:root {
  /* Corporate Colour Palette from Official Logo (#937557) & Menu */
  --bg-main: #FDF9EC;
  --bg-card: #FFFFFF;
  --bg-subtle: #F5EEDC;
  --primary: #937557;       /* Exact Logo Corporate Color */
  --primary-dark: #6E5338;  /* Deep Roasted Herbal Brown */
  --primary-light: #F4EBE1; /* Soft Warm Apricot Tint */
  --accent: #937557;
  --accent-gold: #B6895B;
  --cooling-green: #2F5D3A; /* Menu "COOLING 凉茶" pill color */
  --healthy-brown: #8C5828; /* Menu "HEALTHY DRINKS 养生茶" pill color */
  --dessert-plum: #59315F;  /* Menu "DESSERT 甜品" pill color */
  --text-main: #2C221A;
  --text-muted: #6E5D4F;
  --border-color: #E6D8C3;
  --shadow-sm: 0 3px 12px rgba(147, 117, 87, 0.10);
  --shadow-md: 0 8px 26px rgba(110, 83, 56, 0.16);
  --radius-md: 16px;
  --radius-lg: 22px;
  --app-max-width: 520px;
  --nav-height: 72px;
  --top-bar-height: 74px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: #EAE0CE;
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
}

/* Mobile-first App Frame */
.app-shell {
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--bg-main);
  position: relative;
  padding-bottom: calc(var(--nav-height) + 28px);
  box-shadow: 0 0 42px rgba(68, 48, 28, 0.15);
  overflow-x: clip;
}

/* Top Header Bar (Smart sticky: hides on scroll down, reveals instantly on pull down) */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(253, 249, 236, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  will-change: transform;
}

.top-bar.header-hidden {
  transform: translateY(-100%);
}

.top-bar.header-visible-sticky {
  transform: translateY(0);
  box-shadow: 0 4px 18px rgba(110, 83, 56, 0.12);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  padding: 3px;
  border: 1.5px solid var(--primary);
}

.brand-titles h1 {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
  letter-spacing: 0.5px;
}

.brand-titles p {
  font-size: 0.7rem;
  color: var(--primary-dark);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lang-btn, .icon-btn {
  border: 1.5px solid var(--primary);
  background: var(--bg-card);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.lang-btn:hover, .icon-btn:hover {
  background: var(--primary);
  color: #fff;
}

@media all and (display-mode: standalone), all and (display-mode: fullscreen), all and (display-mode: minimal-ui) {
  #direct-install-btn {
    display: none !important;
  }
}

.lang-switcher {
  display: inline-flex;
  background: var(--bg-card);
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.lang-pill {
  border: none;
  background: transparent;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.lang-pill.active {
  background: var(--primary);
  color: #fff;
}

/* Main Content Views */
.view-section {
  display: none;
  padding: 16px;
  animation: fadeIn 0.22s ease;
}

.view-section.active {
  display: block;
}

/* Page Turn Slide Transitions (翻页滑入视觉动效) */
.view-section.active.slide-from-right {
  animation: pageSlideFromRight 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active.slide-from-left {
  animation: pageSlideFromLeft 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pageSlideFromRight {
  from {
    opacity: 0.15;
    transform: translateX(40px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes pageSlideFromLeft {
  from {
    opacity: 0.15;
    transform: translateX(-40px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Official Corporate Hero Card */
.hero-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #EDE0CA;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border-color);
}

.hero-img-bg {
  width: 100%;
  height: 210px;
  object-fit: cover;
  object-position: center;
  opacity: 1;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(62, 43, 24, 0.94) 15%, rgba(94, 69, 45, 0.45) 100%);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero-badge {
  align-self: flex-start;
  background: rgba(253, 249, 236, 0.22);
  border: 1px solid rgba(253, 249, 236, 0.65);
  color: #FFF6E5;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hero-overlay h2 {
  font-size: 1.32rem;
  line-height: 1.25;
  margin-bottom: 5px;
  color: #FFFDF9;
}

.hero-overlay p {
  font-size: 0.82rem;
  color: rgba(255, 248, 235, 0.92);
}

/* Primary CTA Card for Body Test */
.cta-quiz-banner {
  background: linear-gradient(135deg, #FFFDF8 0%, #F6ECDC 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cta-quiz-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.cta-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(147, 117, 87, 0.3);
}

.cta-avatar-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2.5px solid var(--primary);
  box-shadow: 0 3px 10px rgba(147, 117, 87, 0.28);
}

.cta-quiz-text h3 {
  font-size: 1.02rem;
  color: var(--primary-dark);
  margin-bottom: 3px;
}

.cta-quiz-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(147, 117, 87, 0.32);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--primary-dark);
  border: 1.5px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Five-Free Philosophy Grid */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 8px;
}

.section-header h3 {
  font-size: 1.05rem;
  color: var(--primary-dark);
  font-weight: 800;
}

.section-link {
  font-size: 0.82rem;
  color: var(--primary);
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
}

.five-free-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.five-free-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.five-free-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  text-align: center;
}

.free-item {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 4px;
}

.free-item .free-icon {
  font-size: 1.15rem;
  display: block;
  margin-bottom: 3px;
}

.free-item span {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: block;
  line-height: 1.2;
}

/* Menu Category Banner Headers (matching the PDF Menu style) */
.menu-cat-banner {
  border-radius: 14px;
  padding: 10px 14px;
  color: #fff;
  margin-top: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.menu-cat-banner.cooling {
  background: linear-gradient(90deg, #275332 0%, #3A7248 100%);
}

.menu-cat-banner.healthy {
  background: linear-gradient(90deg, #8A5626 0%, #A96F38 100%);
}

.menu-cat-banner.dessert {
  background: linear-gradient(90deg, #58305E 0%, #784680 100%);
}

.menu-cat-banner h3 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.menu-cat-banner span {
  font-size: 0.75rem;
  opacity: 0.92;
  font-weight: 600;
}

/* Product Cards with Code (A1, B2...) & RM Price Badge */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.product-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  position: relative;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.product-thumb-wrap {
  width: 96px;
  height: 96px;
  background: #FCF6DF;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  position: relative;
}

.product-code-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: var(--primary-dark);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
}

.product-thumb {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.product-info h4 {
  font-size: 0.98rem;
  color: var(--text-main);
  font-weight: 800;
  line-height: 1.25;
}

.price-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.product-herbs {
  font-size: 0.74rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.35;
}

.product-benefits {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 5px;
}

.addon-pill {
  display: inline-block;
  background: #FFF3D6;
  color: #8A5212;
  border: 1px dashed #C88A3B;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 2px;
}

/* Filter Pills */
.filter-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.filter-pill {
  white-space: nowrap;
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* TCM Body Test Interactive Wizard */
.quiz-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.quiz-progress-wrap {
  margin-bottom: 16px;
}

.quiz-step-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 800;
  margin-bottom: 6px;
}

.quiz-progress-bar {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.quiz-question-title {
  font-size: 1.18rem;
  color: var(--primary-dark);
  font-weight: 800;
  margin-bottom: 10px;
  line-height: 1.35;
}

.quiz-symptom-hint {
  background: var(--bg-main);
  border-left: 3.5px solid var(--primary);
  padding: 10px 12px;
  border-radius: 0 10px 10px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-bottom: 16px;
}

.quiz-option-btn {
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  border-radius: 14px;
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.18s ease;
}

.quiz-option-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.quiz-option-main {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.quiz-option-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.quiz-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

/* Result Card */
.result-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.result-title {
  font-size: 1.3rem;
  color: var(--primary-dark);
  font-weight: 800;
  margin-bottom: 10px;
}

.result-explanation {
  font-size: 0.85rem;
  color: var(--text-main);
  background: var(--bg-main);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
}

.rec-drink-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fff;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.rec-drink-item.top-pick {
  border: 2px solid var(--primary);
  background: linear-gradient(to right, #FFFDF9, #F7EFE4);
}

.rec-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-dark);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rec-drink-item.top-pick .rec-rank {
  background: var(--primary);
}

.counter-ticket {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  margin-top: 14px;
  margin-bottom: 14px;
}

.counter-ticket p {
  font-size: 0.75rem;
  opacity: 0.9;
}

.counter-ticket h4 {
  font-size: 1.04rem;
  color: #FFF5E4;
  margin: 4px 0;
}

/* Locations & Story Cards */
.info-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.outlet-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outlet-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.outlet-region {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
}

.outlet-name {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.outlet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.outlet-btn {
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.outlet-btn:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.outlet-btn.fp {
  background: #FCEBF2;
  color: #B81456;
  border-color: #F4C2D7;
}

.outlet-btn.grab {
  background: #E8F7EE;
  color: #007A33;
  border-color: #BCE6CC;
}

.outlet-btn.shopee {
  background: #FFF0EB;
  color: #C93B14;
  border-color: #FAD1C3;
}

.story-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 12px;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  height: var(--nav-height);
  background: rgba(255, 253, 248, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1.5px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(110, 83, 56, 0.08);
  transition: transform 0.22s ease, opacity 0.18s ease;
}

/* Keyboard Active: completely hide bottom-nav so chat input docks directly above keyboard */
body.keyboard-active .bottom-nav {
  display: none !important;
}

body.keyboard-active .chat-input-bar {
  bottom: 0 !important;
}

body.keyboard-active .app-shell {
  padding-bottom: 8px;
}

body.keyboard-active .top-bar {
  transform: translateY(-100%) !important;
}

/* AI大夫 Dialogue Chat Styles */
.ai-header-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #FFFDF8 0%, #F7EFE4 100%);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.ai-header-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--primary);
  box-shadow: 0 2px 8px rgba(147, 117, 87, 0.25);
}

.ai-header-info {
  flex: 1;
  min-width: 0;
}

.btn-new-chat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFDF8;
  border: 1.5px solid var(--primary);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(147, 117, 87, 0.15);
  transition: all 0.2s ease;
}

.btn-new-chat:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(147, 117, 87, 0.25);
}

.btn-new-chat:active {
  transform: scale(0.96);
}

@media (max-width: 480px) {
  .btn-new-chat {
    padding: 5px 9px;
    font-size: 0.74rem;
  }
  .chat-messages {
    padding: 10px 8px;
  }
  .chat-bubble {
    max-width: 88%;
  }
  .chat-bubble.has-recs {
    max-width: 96%;
    width: 100%;
  }
  .chat-rec-card {
    padding: 10px 10px;
    gap: 10px;
  }
  .chat-rec-thumb-wrap {
    width: 44px;
    height: 56px;
  }
  .chat-rec-title {
    font-size: 0.88rem;
  }
  .chat-rec-desc {
    font-size: 0.72rem;
  }
  .chat-rec-price {
    font-size: 0.80rem;
    padding: 2px 7px;
  }
  .chat-rec-action {
    font-size: 0.70rem;
  }
}

/* AI Streaming Chat: Direct flow without restrictive card frame */
#view-ai {
  padding: 10px 14px;
  padding-bottom: calc(var(--nav-height, 72px) + 76px);
}

body.keyboard-active #view-ai {
  padding-bottom: 76px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: transparent;
  padding: 0;
  overflow: visible;
}

.chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  scroll-margin-top: 76px;
}

.chat-row.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  border: 1.5px solid var(--border-color);
}

.chat-avatar-img {
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 2px 6px rgba(147, 117, 87, 0.22);
}

.chat-row.user .chat-avatar {
  background: var(--primary-dark);
}

.chat-bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 15px;
  font-size: 0.84rem;
  line-height: 1.55;
  box-shadow: var(--shadow-sm);
  transition: max-width 0.2s ease;
}

.chat-bubble.has-recs {
  max-width: 94%;
  width: 100%;
}

.chat-row.ai .chat-bubble {
  background: #FFFFFF;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}

.chat-row.user .chat-bubble {
  background: var(--primary);
  color: #FFFFFF;
  border-top-right-radius: 4px;
}

/* Redesigned 3-Row Full-Width Micro Product Card (上：名称，中：功效，下：价格与操作) */
.chat-rec-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FDF9EC;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 3px rgba(147, 117, 87, 0.08);
  text-align: left;
}

.chat-rec-card:hover,
.chat-rec-card:active {
  border-color: var(--primary);
  background: #FAF2DF;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(147, 117, 87, 0.14);
}

.chat-rec-thumb-wrap {
  width: 48px;
  height: 58px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border-radius: 9px;
  border: 1px solid rgba(199, 169, 137, 0.28);
  padding: 3px;
}

.chat-rec-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.chat-rec-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 1. 上行：产品名称（独占整行完整通栏，绝不被价格挤压） */
.chat-rec-title {
  font-size: 0.90rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.25;
  margin-bottom: 3px;
  word-break: break-word;
}

/* 2. 中行：草本功效（独占整行） */
.chat-rec-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-bottom: 5px;
}

/* 3. 下行：价格与查看提示（左右呼应，层次分明） */
.chat-rec-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-rec-price {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: #FFF0D6;
  border: 1px solid #D69E2E;
  padding: 1.5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  line-height: 1.35;
}

.chat-rec-action {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
  transition: transform 0.15s ease;
}

.chat-rec-card:hover .chat-rec-action {
  transform: translateX(2px);
}

.chat-chips-bar {
  padding: 8px 12px;
  background: #FFFDF8;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

/* Milestone TCM Prescription / Wellness Card in Chat */
.tcm-prescription-card {
  background: linear-gradient(135deg, #FFFDF8 0%, #FAF1E2 100%);
  border: 1.8px solid var(--primary);
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
  box-shadow: 0 4px 16px rgba(147, 117, 87, 0.12);
}

.tcm-prescription-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px dashed var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.tcm-prescription-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tcm-prescription-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 6px;
}

.inquiry-btn-group {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inquiry-btn {
  text-align: left;
  background: #FFFDF8;
  border: 1.5px solid var(--primary);
  color: var(--primary-dark);
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inquiry-btn:hover {
  background: #F7EFE4;
  border-color: var(--primary-dark);
  transform: translateY(-1px);
}

.inquiry-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.skip-inquiry-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.skip-inquiry-link:hover {
  color: var(--primary);
}

.chat-chip {
  white-space: nowrap;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--primary-dark);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chat-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.chat-chip.chip-refresh {
  background: linear-gradient(135deg, #FFF6E6 0%, #FFECC7 100%);
  border-color: #E29C28;
  color: #8C4E04;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(226, 156, 40, 0.15);
}

.chat-chip.chip-refresh:hover {
  background: #E29C28;
  color: #FFFFFF;
  border-color: #D38B1B;
}

.chat-input-bar {
  position: fixed;
  bottom: var(--nav-height, 72px);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-width);
  padding: 9px 12px;
  background: rgba(255, 253, 248, 0.98);
  backdrop-filter: blur(14px);
  border-top: 1.5px solid var(--border-color);
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 150;
  box-sizing: border-box;
  box-shadow: 0 -2px 12px rgba(110, 83, 56, 0.08);
  transition: bottom 0.2s ease;
}

body.tab-ai .chat-input-bar,
#view-ai.active ~ .chat-input-bar {
  display: flex;
}

body.keyboard-active .chat-input-bar {
  bottom: 0 !important;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--border-color);
  background: var(--bg-main);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-send-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.84rem;
  padding: 0 16px;
  border-radius: 999px;
  cursor: pointer;
}

.nav-item {
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  transition: color 0.2s ease;
}

.nav-item .nav-icon {
  font-size: 1.28rem;
  line-height: 1;
}

.nav-avatar-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
  box-shadow: 0 1px 4px rgba(147, 117, 87, 0.25);
}

.nav-item.active .nav-avatar-icon {
  transform: translateY(-1px) scale(1.06);
  border-color: var(--primary-dark);
}

.nav-item.active {
  color: var(--primary-dark);
  font-weight: 800;
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

/* Modal Overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 34, 26, 0.65);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: var(--app-max-width);
  max-height: 88vh;
  background: var(--bg-main);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px 28px;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
  border-top: 3px solid var(--primary);
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.herb-box {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.herb-box h5 {
  color: var(--primary-dark);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.herb-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.disclaimer-note {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 12px;
  padding: 10px;
  background: var(--bg-subtle);
  border-radius: 10px;
}

/* Local actions shown when the AI connection is unavailable. */
.offline-chat-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}


/* AI Viewport Stream & Reclaimed Space Styles */
.ai-header-card.in-stream {
  margin-bottom: 12px;
  background: linear-gradient(135deg, #FFFDF8 0%, #F7EFE4 100%);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Quick New Chat Button beside Input */
.chat-reset-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  background: #FFFDF8;
  color: var(--primary-dark);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  padding: 0;
  box-shadow: 0 1px 3px rgba(147, 117, 87, 0.15);
}

.chat-reset-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: rotate(90deg);
}

.chat-reset-btn:active {
  transform: scale(0.92) rotate(180deg);
}

/* Let tablet portrait and landscape layouts use the available screen width. */
@media (min-width: 521px) and (max-width: 1366px) {
  :root {
    --app-max-width: 100%;
  }
}
