/* ============================================
   故人归 H5 全局样式
   ============================================ */

/* ---- Reset & Base ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --color-primary: #E8915A;
  --color-primary-light: #F5D49C;
  --color-bg: #FFF9F2;
  --color-text: #3D2B1F;
  --color-text-light: #8C7B6B;
  --color-success: #52C41A;
  --color-error: #FF4D4F;
  --color-disabled: #D9D9D9;
  --color-white: #FFFFFF;
  --color-card: #FFFFFF;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-3xl: 32px;
  --shadow-sm: 0 2px 8px rgba(61, 43, 31, 0.06);
  --shadow-md: 0 4px 16px rgba(61, 43, 31, 0.08);
  --shadow-lg: 0 8px 32px rgba(61, 43, 31, 0.12);
  --page-padding: 20px;
  --card-gap: 16px;
  --card-padding: 16px;
  --btn-gap: 12px;
  --tab-height: 56px;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", "Source Han Sans CN", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

#app {
  width: 100%;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg);
}

@media (min-width: 768px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
  }
}

/* ---- Page Container ---- */
.page {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

#app-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-scroll {
  flex: 1;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.page-scroll::-webkit-scrollbar {
  width: 4px;
}

.page-scroll::-webkit-scrollbar-thumb {
  background: rgba(232, 145, 90, 0.4);
  border-radius: 2px;
}

.page-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.page-content {
  padding: var(--page-padding);
  padding-bottom: calc(var(--page-padding) + env(safe-area-inset-bottom, 0px));
}

/* ---- Typography ---- */
.title-lg {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
}

.title-md {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
}

.text-body {
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
}

.text-small {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-light);
}

.text-num {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

/* ---- Buttons ---- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn-secondary {
  background: var(--color-white);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border: none;
  font-weight: 400;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: var(--btn-gap);
}

/* ---- Cards ---- */
.card {
  background: var(--color-card);
  border-radius: var(--radius-2xl);
  padding: var(--card-padding);
  box-shadow: var(--shadow-sm);
}

.card-gap + .card-gap {
  margin-top: var(--card-gap);
}

/* ---- Top Navigation Bar ---- */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--page-padding);
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--color-bg);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav-bar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.nav-bar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  color: var(--color-text);
}

/* ---- Bottom Tab Bar ---- */
.tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--tab-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-white);
  border-top: 0.5px solid rgba(61, 43, 31, 0.08);
  flex-shrink: 0;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  color: var(--color-text-light);
  transition: color 0.2s;
}

.tab-item.active {
  color: var(--color-primary);
}

.tab-icon {
  font-size: 22px;
  line-height: 1;
}

/* ---- Login Page ---- */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px var(--page-padding);
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #FFF9F2 0%, #FFF4E8 100%);
}

.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(232, 145, 90, 0.25);
}

.login-brand {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.login-slogan {
  font-size: 16px;
  color: var(--color-text-light);
  margin-bottom: 12px;
}

.login-gift {
  background: rgba(232, 145, 90, 0.1);
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 20px;
  margin-bottom: 28px;
}

/* ---- Auth card（账号密码登录/注册） ---- */
.auth-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(232, 145, 90, 0.12);
  padding: 20px 18px 22px;
  box-sizing: border-box;
}

.auth-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid #f0e7dc;
  margin-bottom: 18px;
}

.auth-tab {
  position: relative;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-light);
  padding-bottom: 10px;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--color-primary);
}

.auth-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-primary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  height: 46px;
  border: 1px solid #ecdfd0;
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--color-text);
  background: #fdfaf6;
  outline: none;
}

.auth-input:focus {
  border-color: var(--color-primary);
  background: #fff;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-tip {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-light);
}

.auth-tip a {
  color: var(--color-primary);
  text-decoration: none;
}

.btn-link {
  margin-top: 20px;
  background: none;
  border: none;
  color: var(--color-text-light);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

.login-buttons {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: var(--btn-gap);
}

.login-agreement {
  margin-top: 32px;
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  line-height: 1.5;
}

.login-agreement a {
  color: var(--color-primary);
  text-decoration: none;
}

/* ---- Home Page ---- */
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--page-padding);
  padding-top: calc(var(--page-padding) + env(safe-area-inset-top, 0px));
}

.home-brand {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

.home-credits {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--color-white);
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  padding: 0 var(--page-padding);
  margin-bottom: 12px;
}

/* ---- Digital Human Cards (2-Column Grid) ---- */
.dh-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 var(--page-padding) 8px;
}

.dh-card {
  width: 100%;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s;
}

.dh-card:active {
  transform: scale(0.97);
}

.dh-card-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-primary-light);
}

.dh-card-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--color-white);
}

.dh-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 96px;
}

.dh-card-relation {
  font-size: 12px;
  color: var(--color-text-light);
}

.dh-card-add {
  width: 100%;
  min-height: 130px;
  background: rgba(232, 145, 90, 0.06);
  border: 1.5px dashed var(--color-primary);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 600;
}

.dh-card-add-icon {
  font-size: 32px;
  line-height: 1;
}

.dh-card-locked {
  width: 100%;
  min-height: 130px;
  background: #f5f5f5;
  border: 1.5px solid #e0e0e0;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: #999;
  font-size: 14px;
  font-weight: 600;
}

.dh-card-locked-icon {
  font-size: 28px;
  line-height: 1;
}

.dh-card-locked-text {
  font-size: 14px;
  font-weight: 600;
  color: #888;
}

.dh-card-locked-sub {
  font-size: 11px;
  color: #bbb;
  font-weight: 400;
}

/* ---- Empty State ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 15px;
  color: var(--color-text-light);
  line-height: 1.6;
}

/* ---- Recent Chat List ---- */
.recent-chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--card-padding);
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin: 0 var(--page-padding) 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s;
}

.recent-chat-item:active {
  transform: scale(0.99);
}

.recent-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-primary-light);
  flex-shrink: 0;
}

.recent-chat-avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-white);
  flex-shrink: 0;
}

.recent-chat-info {
  flex: 1;
  min-width: 0;
}

.recent-chat-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.recent-chat-preview {
  font-size: 13px;
  color: var(--color-text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-chat-time {
  font-size: 12px;
  color: var(--color-text-light);
  flex-shrink: 0;
}

/* ---- Chat Page ---- */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-3d-area {
  flex: 0 0 50%;
  height: 50vh;
  max-height: 50vh;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.chat-3d-canvas {
  width: 100%;
  height: 100%;
  max-height: 50vh;
  display: block;
  background: transparent;
  border-radius: 12px;
  object-fit: contain;
}

.avatar-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--color-text-light);
  z-index: 5;
}

.avatar-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}

.chat-3d-avatar {
  max-width: 240px;
  max-height: 280px;
  width: auto;
  height: auto;
  border-radius: 16px;
  object-fit: cover;
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(232, 145, 90, 0.2);
}

.chat-3d-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--color-white);
  border: 3px solid var(--color-white);
  box-shadow: var(--shadow-md);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px var(--page-padding);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.chat-bubble-ai {
  align-self: flex-start;
  background: var(--color-white);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-white);
  border-bottom-right-radius: 4px;
}

.chat-bubble-time {
  font-size: 11px;
  color: var(--color-text-light);
  margin-top: 4px;
}

.chat-bubble-ai .chat-bubble-time {
  text-align: left;
}

.chat-bubble-user .chat-bubble-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

/* ---- Typing Indicator ---- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-light);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ---- Voice Message in Chat ---- */
.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.voice-msg-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.voice-msg-text {
  font-size: 14px;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  max-width: 60vw;
}

/* ---- Chat Input Bar ---- */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px var(--page-padding);
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--color-white);
  border-top: 0.5px solid rgba(61, 43, 31, 0.06);
  flex-shrink: 0;
}

.chat-input-toggle {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--color-text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-input-field {
  flex: 1;
  min-height: 36px;
  max-height: 100px;
  padding: 8px 14px;
  border: 1px solid var(--color-disabled);
  border-radius: 18px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.4;
}

.chat-input-field:focus {
  border-color: var(--color-primary);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.chat-send-btn:disabled {
  opacity: 0.4;
}

.chat-voice-btn {
  flex: 1;
  height: 36px;
  border: 1px solid var(--color-primary);
  border-radius: 18px;
  background: var(--color-bg);
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Chat Credits Display ---- */
.chat-credits {
  position: absolute;
  top: 8px;
  right: var(--page-padding);
  font-size: 12px;
  color: var(--color-text-light);
  background: rgba(255, 255, 255, 0.8);
  padding: 3px 10px;
  border-radius: 12px;
}

/* ---- Create Flow: Photo Upload ---- */
.create-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.create-nav {
  display: flex;
  align-items: center;
  padding: var(--page-padding);
  padding-top: calc(var(--page-padding) + env(safe-area-inset-top, 0px));
  gap: 12px;
  flex-shrink: 0;
}

.create-title {
  font-size: 18px;
  font-weight: 600;
}

.create-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--page-padding) calc(var(--page-padding) + env(safe-area-inset-bottom, 0px));
}

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 20px;
  border: 2px dashed var(--color-primary);
  border-radius: var(--radius-xl);
  background: rgba(232, 145, 90, 0.04);
  cursor: pointer;
  margin-bottom: 20px;
  transition: background 0.2s;
}

.upload-area:active {
  background: rgba(232, 145, 90, 0.1);
}

.upload-icon {
  font-size: 48px;
  color: var(--color-primary);
}

.upload-text {
  font-size: 15px;
  color: var(--color-text-light);
  text-align: center;
}

.upload-preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.upload-preview img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ---- Progress / Loading ---- */
.progress-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  flex: 1;
}

.progress-spinner {
  width: 64px;
  height: 64px;
  border: 4px solid var(--color-primary-light);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 24px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.progress-subtext {
  font-size: 14px;
  color: var(--color-text-light);
}

.progress-bar {
  width: 100%;
  max-width: 280px;
  height: 6px;
  background: var(--color-primary-light);
  border-radius: 3px;
  margin-top: 20px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ---- Voice Recording ---- */
.record-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 20px;
  flex: 1;
}

.record-guide {
  font-size: 15px;
  color: var(--color-text-light);
  text-align: center;
  line-height: 1.8;
  max-width: 280px;
}

.record-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(232, 145, 90, 0.35);
  transition: transform 0.15s;
  user-select: none;
}

.record-btn:active,
.record-btn.recording {
  transform: scale(1.1);
  background: var(--color-error);
}

.record-btn-icon {
  font-size: 32px;
  line-height: 1;
}

.record-duration {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* Sound wave animation */
.wave-container {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}

.wave-bar {
  width: 4px;
  background: var(--color-primary);
  border-radius: 2px;
  animation: wave 0.8s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }
.wave-bar:nth-child(6) { animation-delay: 0.15s; }
.wave-bar:nth-child(7) { animation-delay: 0.25s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

.record-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 300px;
}

/* ---- Personality Questionnaire ---- */
.questionnaire-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px var(--page-padding);
  flex-shrink: 0;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-disabled);
  transition: background 0.3s;
}

.progress-dot.active {
  background: var(--color-primary);
}

.progress-dot.completed {
  background: var(--color-primary);
}

.progress-line {
  width: 30px;
  height: 2px;
  background: var(--color-disabled);
  transition: background 0.3s;
}

.progress-line.completed {
  background: var(--color-primary);
}

.question-section {
  padding: 0 var(--page-padding) 20px;
}

.question-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.question-hint {
  font-size: 13px;
  color: var(--color-text-light);
  margin-bottom: 12px;
}

.question-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1.5px solid var(--color-disabled);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: var(--color-white);
  color: var(--color-text);
  resize: vertical;
}

.question-input:focus {
  border-color: var(--color-primary);
}

.question-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 16px;
  border: 1.5px solid var(--color-disabled);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  background: var(--color-white);
  color: var(--color-text);
  resize: vertical;
  line-height: 1.6;
}

.question-textarea:focus {
  border-color: var(--color-primary);
}

/* ---- Tag Selector ---- */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-item {
  padding: 8px 18px;
  border: 1.5px solid var(--color-disabled);
  border-radius: 20px;
  font-size: 14px;
  color: var(--color-text-light);
  cursor: pointer;
  background: var(--color-white);
  transition: all 0.15s;
  user-select: none;
}

.tag-item.selected {
  border-color: var(--color-primary);
  background: rgba(232, 145, 90, 0.1);
  color: var(--color-primary);
  font-weight: 600;
}

.question-nav {
  display: flex;
  gap: 12px;
  padding: 20px var(--page-padding);
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px) + 34px);
  flex-shrink: 0;
}

/* ---- Done Page ---- */
.done-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
}

.done-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--color-white);
  margin-bottom: 24px;
  animation: popIn 0.5s ease;
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.done-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.done-subtitle {
  font-size: 15px;
  color: var(--color-text-light);
  margin-bottom: 40px;
}

.done-actions {
  width: 100%;
  max-width: 300px;
}

/* 后台生成迷你进度条 */
.gen-mini-bar {
  width: 100%;
  max-width: 240px;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px auto 0;
}
.gen-mini-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #D4793E);
  border-radius: 999px;
  transition: width .4s ease;
}
.gen-fail {
  margin-top: 14px;
  font-size: 14px;
  color: #d64545;
}

/* ---- Credits Page ---- */
.credits-card {
  background: linear-gradient(135deg, var(--color-primary) 0%, #D4793E 100%);
  border-radius: var(--radius-2xl);
  padding: 28px 24px;
  margin: 0 var(--page-padding) var(--card-gap);
  color: var(--color-white);
  text-align: center;
}

.credits-label {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 8px;
}

.credits-num {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
}

.credits-yuan {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 8px;
}

.credits-stats {
  display: flex;
  justify-content: space-around;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.credits-stat-item {
  text-align: center;
}

.credits-stat-num {
  font-size: 18px;
  font-weight: 600;
}

.credits-stat-label {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

.recharge-plans {
  padding: 0 var(--page-padding);
  margin-bottom: var(--card-gap);
}

.recharge-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}

.recharge-plan.selected {
  border-color: var(--color-primary);
}

.recharge-plan-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recharge-plan-credits {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}

.recharge-plan-price {
  font-size: 14px;
  color: var(--color-text-light);
}

.recharge-plan-tag {
  font-size: 12px;
  color: var(--color-primary);
  background: rgba(232, 145, 90, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
}

/* ---- Credits Records ---- */
.record-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--card-padding);
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin: 0 var(--page-padding) 8px;
  box-shadow: var(--shadow-sm);
}

.record-info {
  flex: 1;
  min-width: 0;
}

.record-desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 2px;
}

.record-time {
  font-size: 12px;
  color: var(--color-text-light);
}

.record-amount {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.record-amount.income {
  color: var(--color-success);
}

.record-amount.expense {
  color: var(--color-primary);
}

/* ---- Profile Page ---- */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: var(--page-padding);
  padding-top: calc(var(--page-padding) + env(safe-area-inset-top, 0px));
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--color-white);
  flex-shrink: 0;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.profile-meta {
  font-size: 13px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.profile-menu {
  padding: 0 var(--page-padding);
}

.profile-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.profile-menu-item:active {
  background: rgba(0, 0, 0, 0.02);
}

.profile-menu-label {
  font-size: 15px;
  color: var(--color-text);
}

.profile-menu-arrow {
  font-size: 18px;
  color: var(--color-text-light);
}

.logout-btn {
  margin: 24px var(--page-padding);
  text-align: center;
  padding: 14px;
  font-size: 15px;
  color: var(--color-error);
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* ---- Memory Page ---- */
.memory-list {
  padding: 0 var(--page-padding);
}

.memory-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--card-padding);
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.memory-content {
  flex: 1;
  font-size: 15px;
  color: var(--color-text);
  line-height: 1.5;
}

.memory-time {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 4px;
}

.memory-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-error);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memory-add-section {
  padding: var(--page-padding);
  display: flex;
  gap: 8px;
}

.memory-add-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--color-disabled);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--color-white);
  color: var(--color-text);
  resize: none;
  max-height: 80px;
}

.memory-add-input:focus {
  border-color: var(--color-primary);
}

.memory-add-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(61, 43, 31, 0.85);
  color: var(--color-white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 9999;
  max-width: 80%;
  text-align: center;
  pointer-events: none;
  animation: toastFade 0.3s ease;
}

.toast.success {
  background: var(--color-success);
}

.toast.error {
  background: var(--color-error);
}

@keyframes toastFade {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

/* ---- Utility ---- */
.flex-spacer {
  flex: 1;
}

.text-center {
  text-align: center;
}

.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.hidden {
  display: none !important;
}

/* ---- Loading Overlay ---- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 249, 242, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}

.loading-overlay .progress-spinner {
  margin-bottom: 0;
}

/* ============================================
   New Pages Styles
   ============================================ */

/* ---- Small Button ---- */
.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

/* ---- Nav Bar Text Button ---- */
.nav-bar-text-btn {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  width: auto;
  padding: 0 4px;
}

/* ---- Settings Page ---- */
.settings-list {
  padding: var(--page-padding);
  background: var(--color-white);
  border-radius: var(--radius-lg);
  margin: var(--page-padding);
  box-shadow: var(--shadow-sm);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 0.5px solid rgba(61, 43, 31, 0.08);
  cursor: pointer;
}

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

.settings-item-label {
  font-size: 15px;
  color: var(--color-text);
}

.settings-item-value {
  font-size: 14px;
  color: var(--color-text-light);
}

/* ---- Toggle Switch ---- */
.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--color-disabled);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
  flex-shrink: 0;
}

.toggle-switch.on {
  background: var(--color-primary);
}

.toggle-knob {
  width: 20px;
  height: 20px;
  background: var(--color-white);
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.on .toggle-knob {
  transform: translateX(20px);
}

/* ---- Detail Page ---- */
.detail-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px var(--page-padding) 16px;
}

.detail-avatar {
  width: 120px;
  height: 160px;
  border-radius: 12px;
  object-fit: cover;
  object-position: top center;
  box-shadow: var(--shadow-md);
}

.detail-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-text);
  font-size: 32px;
  font-weight: 600;
}

.detail-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 12px;
}

.detail-relation-tag {
  font-size: 13px;
  color: var(--color-primary);
  background: rgba(232, 145, 90, 0.1);
  padding: 2px 12px;
  border-radius: 10px;
  margin-top: 6px;
}

.detail-card {
  margin: 0 var(--page-padding) var(--card-gap);
}

.detail-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

.detail-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.detail-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 0.5px solid rgba(61, 43, 31, 0.06);
}

.detail-info-label {
  font-size: 14px;
  color: var(--color-text-light);
  flex-shrink: 0;
}

.detail-info-value {
  font-size: 14px;
  color: var(--color-text);
  text-align: right;
}

.detail-edit-input {
  flex: 1;
  max-width: 180px;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
  text-align: right;
  outline: none;
}

.detail-edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tag {
  font-size: 13px;
  color: var(--color-text);
  background: rgba(232, 145, 90, 0.1);
  padding: 4px 12px;
  border-radius: 10px;
}

.detail-action-row {
  display: flex;
  gap: var(--btn-gap);
}

.detail-action-row .btn {
  flex: 1;
}

.detail-delete-btn {
  text-align: center;
  padding: 16px;
  font-size: 15px;
  color: var(--color-error);
  margin: 8px var(--page-padding) 32px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.detail-loading {
  text-align: center;
  padding: 40px;
  color: var(--color-text-light);
  font-size: 14px;
}

/* ---- Confirm Dialog ---- */
.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.confirm-dialog {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 80%;
  max-width: 300px;
  text-align: center;
}

.confirm-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
}

.confirm-message {
  font-size: 14px;
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 20px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

.confirm-actions .btn {
  flex: 1;
}

/* ---- Voice Manage Page ---- */
.voice-tip {
  text-align: center;
  font-size: 13px;
  color: var(--color-text-light);
  padding: 16px var(--page-padding);
  line-height: 1.6;
}

.voice-record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 24px;
  position: relative;
}

.voice-record-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 16px rgba(232, 145, 90, 0.4);
  transition: transform 0.2s;
}

.voice-record-btn:active {
  transform: scale(0.95);
}

.voice-record-btn.recording {
  background: var(--color-error);
  box-shadow: 0 4px 16px rgba(255, 77, 79, 0.4);
}

.voice-ripple {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--color-error);
  animation: voiceRipple 1.5s ease-out infinite;
}

@keyframes voiceRipple {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.voice-record-icon {
  font-size: 28px;
  color: var(--color-white);
}

.voice-record-text {
  font-size: 12px;
  color: var(--color-white);
  margin-top: 4px;
}

.voice-record-time {
  font-size: 14px;
  color: var(--color-text);
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

.voice-upload-link {
  text-align: center;
  font-size: 14px;
  color: var(--color-primary);
  padding: 8px;
  cursor: pointer;
}

.voice-sample-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--card-padding);
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin: 0 var(--page-padding) 8px;
  box-shadow: var(--shadow-sm);
}

.voice-sample-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(232, 145, 90, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.voice-sample-info {
  flex: 1;
}

.voice-sample-duration {
  font-size: 14px;
  color: var(--color-text);
}

.voice-sample-status {
  font-size: 12px;
  margin-top: 2px;
}

.voice-sample-status.done {
  color: var(--color-success);
}

.voice-sample-status.processing {
  color: var(--color-text-light);
}

.voice-sample-status.failed {
  color: var(--color-error);
}

.voice-sample-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(232, 145, 90, 0.1);
  color: var(--color-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.voice-sample-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(232, 145, 90, 0.2);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Recharge Records Page ---- */
.record-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--card-padding);
  background: var(--color-white);
  border-radius: var(--radius-md);
  margin: 0 var(--page-padding) 8px;
  box-shadow: var(--shadow-sm);
}

.record-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.record-in {
  background: rgba(82, 196, 26, 0.1);
  color: var(--color-success);
}

.record-out {
  background: rgba(255, 149, 0, 0.1);
  color: #FF9500;
}

.record-info {
  flex: 1;
}

.record-desc {
  font-size: 14px;
  color: var(--color-text);
}

.record-time {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.record-amount {
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}

.record-in-text {
  color: var(--color-success);
}

.record-out-text {
  color: #FF9500;
}

.record-loading {
  text-align: center;
  padding: 16px;
  color: var(--color-text-light);
  font-size: 14px;
}

.record-nomore {
  text-align: center;
  padding: 16px;
  color: var(--color-text-light);
  font-size: 13px;
}

/* ---- Legal Content (Agreement & Privacy) ---- */
.legal-content {
  padding: var(--page-padding);
  padding-bottom: 40px;
}

.legal-content p {
  font-size: 14px;
  line-height: 1.8;
  color: var(--color-text);
  margin-bottom: 12px;
}

.legal-intro {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.legal-updated {
  font-size: 13px;
  color: var(--color-text-light);
  text-align: center;
  margin-bottom: 20px;
}

.legal-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 20px;
  margin-bottom: 8px;
}

.avatar-error-msg {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-top: 8px;
  text-align: center;
}

/* ============================================
   Avatar Portrait (CSS mode)
   ============================================ */
.avatar-portrait-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Canvas-based avatar (main display) */
.avatar-portrait-canvas {
  max-width: 75%;
  max-height: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 30px rgba(100,140,200,0.2)) drop-shadow(0 2px 8px rgba(0,0,0,0.06));
  transition: filter 0.3s ease;
}

/* Fallback img (shown before canvas is ready) */
.avatar-portrait-img {
  max-width: 75%;
  max-height: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 30px rgba(100,140,200,0.2)) drop-shadow(0 2px 8px rgba(0,0,0,0.06));
}

/* Phone fullscreen mode */
.avatar-portrait-wrap.phone-fs {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.avatar-portrait-img.img-fs {
  max-width: 90vw;
  max-height: 75vh;
}

.avatar-portrait-canvas.img-fs {
  max-width: 90vw;
  max-height: 75vh;
}

.avatar-portrait-canvas.img-fs {
  max-width: 90vw;
  max-height: 75vh;
}


/* === Avatar Zoom Control (v=20260812d) === */
.avatar-zoom-control {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  z-index: 10;
}

.zoom-label {
  font-size: 14px;
  opacity: 0.7;
}

.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  border-radius: 2px;
  background: #ddd;
  outline: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #D2691E;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #D2691E;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.zoom-value {
  font-size: 12px;
  color: #666;
  min-width: 36px;
  text-align: right;
}

/* White gradient background for avatar area (like 4th phase) */
.chat-3d-area {
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f5 100%) !important;
}

/* ===== 3D视频通话内嵌模式：头像全屏 + 文字浮层无背景 ===== */
.video-mode {
  background: #000;
}

.video-mode .nav-bar {
  display: none !important;
}

/* 视频通话时隐藏普通头像区 */
.video-mode .chat-3d-area {
  display: none !important;
}

/* 视频通话时隐藏输入栏（只看不说，挂断后回来继续聊） */
.video-mode .chat-input-bar {
  display: none !important;
}

/* 全屏视频区域 */
.video-mode .video-call-area {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: #000;
}

.video-call-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* 通话模式：聊天消息浮在视频上方，无背景，文字直接出现 */
.video-mode .chat-messages {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 150;
  padding: 16px 16px 120px;
  background: transparent !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}

.video-mode .chat-messages .chat-bubble {
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7), 0 0 8px rgba(0,0,0,0.5);
  max-width: 85%;
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1.5;
  pointer-events: auto;
}

.video-mode .chat-messages .chat-bubble-user {
  align-self: flex-end;
  color: rgba(255,220,150,0.95);
}

.video-mode .chat-messages .chat-bubble-ai {
  align-self: flex-start;
  color: #fff;
}

.video-mode .chat-messages .chat-bubble-time,
.video-mode .chat-messages .voice-msg,
.video-mode .chat-messages .typing-indicator {
  display: none !important;
}

.video-hangup {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 200;
  width: 56px;
  height: 56px;
  padding: 0;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(135deg, #ff4444, #cc0000);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-hangup:active {
  transform: scale(0.92);
}

.video-hangup:active {
  transform: translateX(-50%) scale(0.96);
}

/* ===== 空状态引导 ===== */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

.chat-empty-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light, #e8a060), var(--color-primary, #d4844a));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(232,145,90,0.3);
}

.chat-empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text, #333);
  margin-bottom: 20px;
}

.chat-empty-suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

.chat-suggestion-chip {
  padding: 12px 18px;
  background: var(--color-white, #fff);
  border: 1px solid var(--color-border, #e8e0d8);
  border-radius: 20px;
  font-size: 14px;
  color: var(--color-text, #555);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-suggestion-chip:active {
  background: var(--color-primary-light, #f5e6d3);
  transform: scale(0.97);
}

/* ===== 历史记录弹窗 ===== */
.history-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.history-modal {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: var(--color-bg, #faf8f5);
  border-radius: 20px 20px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.history-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #e8e0d8);
  font-size: 16px;
  font-weight: 600;
}

.history-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-light, #999);
  padding: 4px 8px;
}

.history-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

.history-loading,
.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-light, #999);
  font-size: 14px;
}

.history-item {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
}

.history-item:active {
  background: rgba(232,145,90,0.08);
}

.history-item-role {
  font-size: 12px;
  color: var(--color-primary, #d4844a);
  font-weight: 600;
  margin-bottom: 4px;
}

.history-item-content {
  font-size: 14px;
  color: var(--color-text, #333);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-time {
  font-size: 11px;
  color: var(--color-text-light, #aaa);
  margin-top: 4px;
}

/* 通话模式隐藏空状态提示 */
.video-mode .chat-empty-state {
    display: none !important;
}


/* ============================================================
   v21: 通话中H5聊天气泡层整体隐藏（字幕由OAC iframe内专属字幕层显示，
   避免碎片气泡竖排、避免气泡盖住挂断按钮）
   ============================================================ */
.video-mode .chat-messages,
.video-mode .typing-indicator {
    display: none !important;
}

/* v21: 挂断按钮上移到底部字幕渐变区之上，永远可点 */
.video-hangup {
    bottom: 96px !important;
    right: 24px !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
}

/* ============================================================
   v23: 挂断按钮触摸加固（双保险之一，配合OAC iframe内挂断钮）
   ============================================================ */
.video-hangup {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* ===== 2026-09-27 易用性修复 ===== */
/* 照片上传正面照提示 */
.upload-tips {
  margin-top:14px; font-size:13px; line-height:1.7; color:#8a6d4b;
  background:#fbf4ea; border:1px solid #f0e2cd; border-radius:12px;
  padding:12px 14px; width:100%; max-width:340px;
}
/* 声音克隆不确定进度条 */
.indeterminate-bar {
  width:100%; max-width:240px; height:6px; background:rgba(0,0,0,.08);
  border-radius:999px; overflow:hidden; position:relative; margin:20px auto 0;
}
.indeterminate-fill {
  position:absolute; top:0; left:0; height:100%; width:40%;
  background:linear-gradient(90deg,var(--color-primary),#D4793E);
  border-radius:999px;
  animation:indetSlide 1.2s ease-in-out infinite;
}
@keyframes indetSlide {
  0% { left:-40%; }
  100% { left:100%; }
}
/* 首页生成中卡片 */
.dh-card-creating { position:relative; }
.dh-avatar-pending { opacity:.6; filter:grayscale(.3); }
.dh-card-genstatus {
  font-size:12px; color:var(--color-primary); margin-top:4px;
  display:flex; align-items:center; justify-content:center; gap:5px;
}
.gen-dot {
  width:7px; height:7px; border-radius:50%; background:var(--color-primary);
  animation:genPulse 1s ease-in-out infinite;
}
@keyframes genPulse {
  0%,100% { opacity:.3; transform:scale(.8); }
  50% { opacity:1; transform:scale(1.15); }
}

/* 20261009 照片自动上传提示 */
.auto-upload-tip {
  margin: 12px 0 4px;
  text-align: center;
  font-size: 14px;
  color: var(--color-primary, #8a5a44);
}
