/* App Mockup Specific Styles - Replicating Flutter UI */
:root {
  /* YGS Design Tokens from Flutter */
  --app-primary: #E22626;
  --app-text-primary: #151523;
  --app-text-secondary: #868691;
  --app-text-tertiary: #B6B6BD;
  --app-bg-primary: #F4F7FA;
  --app-bg-card: #FFFFFF;
  --app-border: #DEE1E5;
  --app-divider: #EDF0F6;
  --app-halo-gold: #FFD700;
}

/* Hide Scrollbars */
.story-scroll-view, 
.screen-citation,
.character-section {
  scrollbar-width: none; 
  -ms-overflow-style: none;
}
.story-scroll-view::-webkit-scrollbar,
.screen-citation::-webkit-scrollbar,
.character-section::-webkit-scrollbar { 
  display: none; 
}

/* Phone Container Override */
.phone-mockup {
  display: block !important; 
  align-items: unset;
  justify-content: unset;
  
  /* Reset to clean 2D by default for maximum sharpness */
  transform: none;
  backface-visibility: hidden;
  will-change: transform, opacity;

  /* Inline character card baseline tuning. */
  --inline-char-card-shift: -1px;
  --inline-char-card-auto-shift: 0px;
  
  background: #FFF; 
  border: 10px solid #F2F2F2; /* Titanium Frame */
  border-radius: 48px;
  
  /* Refined soft shadow */
  box-shadow: 
    0 0 0 1px rgba(0,0,0,0.05),
    0 20px 40px -12px rgba(0,0,0,0.12);
    
  width: min(320px, 100%);
  max-width: 100%;
  height: 650px; 
  position: relative;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

/* Mockup Gallery (Direct Expansion on Mobile) */
.mockup-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  width: 100%;
  padding: 0 0 60px;
}

.mockup-item {
  flex: 0 0 auto;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Silky Reveal Animation for Mobile List */
.mockup-item.reveal {
  opacity: 0;
  transform: translateY(40px) scale(0.96);
  transition: transform 0.8s cubic-bezier(0.2, 1, 0.3, 1), opacity 0.8s ease;
  will-change: transform, opacity;
}

.mockup-item.reveal.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.mockup-caption {
  font-size: 13px;
  line-height: 1.4;
  color: var(--app-text-secondary);
  text-align: center;
  opacity: 0.8;
}

.mockup-carousel-controls {
  display: none; /* Only used in carousel mode on desktop */
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 0;
  user-select: none;
}

.mockup-carousel-dot {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mockup-carousel-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  border: 1px solid var(--app-border);
  background: rgba(44, 44, 44, 0.14);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.mockup-carousel-dot:hover::before {
  transform: scale(1.1);
  background: rgba(44, 44, 44, 0.22);
}

.mockup-carousel-dot:focus-visible {
  outline: 2px solid var(--app-primary);
  outline-offset: 4px;
}

.mockup-carousel-dot.is-active::before {
  background: var(--app-primary);
  border-color: var(--app-primary);
  width: 16px;
  transform: none;
}

@media (min-width: 901px) {
  .mockup-stack {
    padding: 0;
  }

  .mockup-stack.is-carousel {
    display: grid;
    grid-template-columns: 1fr; /* Add explicit single column */
    grid-template-rows: auto auto;
    justify-items: center;
    align-items: start;
    position: relative;
    perspective: 1000px;
    transform-style: preserve-3d;
    gap: 24px;
    padding: 20px 0 40px; /* Buffer for shadows */
    --mockup-carousel-enter-x: 80px;
    --mockup-carousel-exit-x: -60px;
    --mockup-carousel-rotate: 4deg;
  }

  .mockup-stack.is-carousel[data-carousel-direction='backward'] {
    --mockup-carousel-enter-x: -80px;
    --mockup-carousel-exit-x: 60px;
    --mockup-carousel-rotate: -4deg;
  }

  /* Reset reveal animation for desktop carousel items to avoid conflict */
  .mockup-stack.is-carousel > .mockup-item.reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .mockup-stack.is-carousel > .mockup-item {
    display: flex; /* Always display to keep render tree stable */
    visibility: hidden;
    opacity: 0;
    grid-row: 1;
    grid-column: 1;
    width: auto;
    will-change: transform, opacity;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    pointer-events: none; /* Prevent interaction when hidden */
    transition: visibility 0s linear 0.7s; /* Delay visibility change until animation ends */
  }

  .mockup-stack.is-carousel > .mockup-item.is-active {
    visibility: visible;
    opacity: 1;
    z-index: 2;
    pointer-events: auto;
    transition: visibility 0s;
    animation: mockup-carousel-enter 0.7s cubic-bezier(0.19, 1, 0.22, 1);
  }

  .mockup-stack.is-carousel > .mockup-item.is-exiting {
    visibility: visible;
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    transition: visibility 0s;
    animation: mockup-carousel-exit 0.6s cubic-bezier(0.19, 1, 0.22, 1);
  }

  .mockup-stack.is-carousel > .mockup-carousel-controls {
    display: flex;
    grid-row: 2;
    grid-column: 1;
    z-index: 2;
  }

  .mockup-stack.is-carousel .phone-mockup .mockup-carousel-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.9);
    pointer-events: none;
    position: absolute;
    left: 50%;
    bottom: 84px;
    z-index: 120;
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .mockup-stack.is-carousel .phone-mockup .mockup-carousel-hint.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes mockup-carousel-enter {
  from {
    opacity: 0;
    transform: translate3d(var(--mockup-carousel-enter-x), 10px, -100px) rotateY(var(--mockup-carousel-rotate)) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotateY(0) scale(1);
  }
}

@keyframes mockup-carousel-exit {
  from {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate3d(var(--mockup-carousel-exit-x), -10px, -50px) rotateY(calc(var(--mockup-carousel-rotate) * -0.5)) scale(0.95);
  }
}

@media (prefers-color-scheme: dark) {
  .mockup-carousel-dot::before {
    background: rgba(255, 255, 255, 0.16);
  }

  .mockup-carousel-dot:hover::before {
    background: rgba(255, 255, 255, 0.24);
  }
}

.phone-mockup.is-static:hover {
  transform: none;
}

.phone-mockup.is-static .story-scroll-view {
  overflow-y: hidden;
  -webkit-mask-image: none;
  mask-image: none;
}

.phone-mockup.is-static .screen-citation {
  overflow-y: hidden;
}

.phone-mockup.is-static .character-section {
  overflow-x: hidden;
}

/* App Screen */
.app-screen-container {
  display: flex;
  width: 100%;
  height: 100%;
}

.app-screen {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  height: 100%;
  position: relative;
  background: var(--app-bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- Common UI --- */

/* Status Bar */
.status-bar {
  height: 44px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px 0 32px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(0,0,0,0.5);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 16px;
}

.status-icon img {
  height: 14px;
  width: auto;
  display: block;
  object-fit: contain;
}

.status-icon svg {
  height: 14px;
  width: auto;
  stroke: #000; 
  fill: none;   
  display: block;
}

.phone-notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 26px; background: #111; border-radius: 13px; z-index: 30;
}

.home-indicator {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 5px; background: #000; border-radius: 3px; z-index: 100; opacity: 0.8;
}

/* --- Screen 1: Story Detail --- */

.screen-story { background: var(--app-bg-card); }

.app-nav-bar {
  height: 48px; margin-top: 44px; display: flex; justify-content: space-between;
  align-items: center; padding: 0 16px; z-index: 10; background: var(--app-bg-card);
}

.app-nav-bar.reading-mode {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

.nav-icon {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--app-text-primary); cursor: pointer; flex-shrink: 0; overflow: hidden;
}
.nav-icon img { width: 20px !important; height: 20px !important; display: block; object-fit: contain; }

.nav-center-mini {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 4px;
}
.mini-avatar {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.05); display: block;
}
.mini-title {
  font-family: "Noto Serif SC", serif; font-size: 13px; font-weight: 700;
  color: var(--app-text-primary); max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.story-scroll-view {
  flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 80px; position: relative;
}

.story-header { padding: 4px 20px 0; text-align: center; background: var(--app-bg-card); }

.story-title {
  font-family: "Noto Serif SC", serif; font-size: 20px; font-weight: 700;
  color: var(--app-text-primary); line-height: 1.4; margin-bottom: 12px;
  min-height: 32px; display: flex; align-items: center; justify-content: center;
}

.story-meta {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  flex-wrap: wrap; row-gap: 6px;
  margin-bottom: 12px;
}
.meta-item {
  display: flex; align-items: center; gap: 4px; font-size: 10px; color: #999; font-weight: 400; letter-spacing: 0.2px;
}
.meta-item svg { width: 12px; height: 12px; color: #CCC; }

/* Character Section */
.character-section {
  margin: 0 20px 18px; padding: 12px 16px;
  background: #F7F9FC; border-radius: 10px;
  overflow-x: auto;
}
.character-grid { display: flex; gap: 12px; justify-content: flex-start; }

.character-section--ultra { padding: 10px 12px; }
.character-section--ultra .character-grid { gap: 4px; }
.character-section--ultra .char-tile { width: 34px; gap: 3px; }
.character-section--ultra .char-tile-avatar { width: 24px; height: 24px; }
.character-section--ultra .char-tile-name { font-size: 10px; }
.character-section--ultra .char-tile-role { font-size: 8px; padding: 0px 4px; }

.char-tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; width: 42px; flex-shrink: 0;
}
.char-tile-avatar {
  width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #FFF;
  overflow: hidden; background: #FFF; box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}
.char-tile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-tile-name {
  font-size: 11px; color: #333; font-weight: 600; text-align: center;
  line-height: 1.2; white-space: nowrap; width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.char-tile-role {
  font-size: 9px; color: #999; background: rgba(0,0,0,0.03); padding: 0px 5px;
  border-radius: 4px; margin-top: 0px; line-height: 1.3;
}

/* Story Body */
.story-body {
  padding: 0 20px; font-size: 13px; line-height: 1.7; color: #333;
  text-align: justify; letter-spacing: 0.2px;
}
.story-body p { margin-top: 0; margin-bottom: 14px; }

/* Inline Card */
.inline-char-card {
  /* Use inline-flex so avatar/text share a single visual center. */
  display: inline-flex;
  align-items: center;
  /* Avoid inheriting large paragraph line-height */
  line-height: 1;
  /* Align the chip to the surrounding text. */
  vertical-align: middle;
  transform: translateY(
    calc(var(--inline-char-card-shift, 0px) + var(--inline-char-card-auto-shift, 0px))
  );
  /* Tighter spacing to fuse with surrounding text (especially on the right side). */
  margin: 0 1px 0 2px;
  white-space: nowrap;
  background: #F0F4F8; border: 1px solid rgba(0,0,0,0.05);
  border-radius: 4px; padding: 0px 5px 0px 1.5px;
  cursor: pointer; transition: background-color 0.2s, border-color 0.2s;
}
.inline-char-card:hover { background: #E5EBF2; border-color: rgba(0,0,0,0.1); }
.inline-char-avatar {
  flex: 0 0 auto;
  width: 14px; height: 14px; border-radius: 50%; overflow: hidden;
  margin-right: 4px; background: #DDD;
}
.inline-char-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inline-char-name {
  flex: 0 0 auto;
  font-size: 13px; color: #222; font-weight: 400; line-height: 1; letter-spacing: 0px;
}

/* Story Image Block */
.story-image-block {
  margin: 20px 0; border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); background: #FFF; border: 1px solid rgba(0,0,0,0.02);
}
.story-image-block.flat {
  box-shadow: none; border: none; background: transparent;
  margin: 14px 0 10px; border-radius: 4px;
}
.story-image-block.flat .story-image-caption {
  background: transparent; border: none; padding: 2px 0 0;
  text-align: center; color: #999; font-size: 10px; margin-bottom: 0;
}
.story-image-block img { width: 100%; height: auto; display: block; }
.story-image-caption {
  padding: 8px 12px; font-size: 11px; color: #888; text-align: center;
  background: #FFF; border-top: 1px solid rgba(0,0,0,0.03); line-height: 1.4;
}

/* Bottom Input */
.bottom-input-bar {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 72px;
  background: #FFF; border-top: 1px solid rgba(0,0,0,0.04);
  padding: 8px 16px 24px; display: flex; align-items: center;
}
.input-mock {
  flex: 1; height: 34px; background: #F7F7F7; border-radius: 17px;
  padding: 0 14px; display: flex; align-items: center; font-size: 12px; color: #AAA;
}

/* --- Screen 2: Citation (Reference List - Refined) --- */
.screen-citation {
  background: #FFF; 
  padding: 56px 16px 18px; /* Top padding for status bar */
  overflow-y: auto;
  text-align: left;
}

/* Quote Item Container */
.quote-item {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0,0,0,0.05); /* Separator */
  position: relative;
}
.quote-item:last-child {
  border-bottom: none; margin-bottom: 0; padding-bottom: 0;
}

/* 1. Quote Icon Box */
.quote-icon-box {
  width: 20px; height: 20px;
  background: rgba(80, 125, 175, 0.1); 
  border: 1px solid rgba(80, 125, 175, 0.2);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  color: #507DAF; margin-bottom: 8px;
}
.quote-icon-box svg { width: 12px; height: 12px; fill: currentColor; display: block; }

/* 2. Big Character Name */
.quote-big-name {
  font-family: "PingFang SC", sans-serif; font-size: 17px; font-weight: 600;
  color: #2A2A39; margin-left: 4px; margin-bottom: 6px;
}

/* 3. Source Info Row */
.quote-source-row {
  display: flex; align-items: center; margin-bottom: 10px; padding-left: 4px;
}
.quote-source-text { flex: 1; min-width: 0; }
.source-meta { font-size: 11px; color: #868691; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-author { color: #507DAF; font-weight: 600; }
.source-title {
  font-size: 13px; font-weight: 700; color: #2A2A39; font-family: "Noto Serif SC", serif; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 4. Content Card - Shadow Style, No Border */
.quote-content-card {
  background: #FFF;
  border: none; /* Removed border */
  /* Enhanced soft shadow for depth */
  box-shadow: 0 4px 14px rgba(0,0,0,0.06); 
  border-radius: 6px; 
  padding: 10px; 
  margin-bottom: 6px; 
  font-size: 13px; line-height: 1.55; color: #151523; text-align: justify;
  max-height: calc(3 * 1.55em + 20px);
  overflow: hidden;
}

/* Author Avatar Group - Vertical Stack */
.source-avatar-group {
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  margin-left: 10px; 
  flex-shrink: 0;
  width: 44px; /* Fixed width for alignment */
}

.source-avatar-container {
  width: 34px; 
  height: 34px; 
  border-radius: 50%;
  border: 1px solid rgba(80, 125, 175, 0.2); 
  padding: 2px;
  margin-bottom: 4px;
}
.source-avatar { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.source-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Name & Role Labels */
.source-author-name {
  font-size: 10px;
  color: #333;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.source-author-role {
  font-size: 8px;
  color: #888;
  background: rgba(0,0,0,0.04);
  padding: 0 4px;
  border-radius: 4px;
  margin-top: 2px;
  line-height: 1.3;
  white-space: nowrap;
}

/* Contextual Override: Inline Card inside Quote */
.quote-content-card .inline-char-card {
  background: rgba(80, 125, 175, 0.08); /* Blue Tint */
  border-color: rgba(80, 125, 175, 0.2);
  padding: 0px 5px 0px 1px;
}
.quote-content-card .inline-char-name {
  color: #507DAF; font-weight: 500; font-size: 12px;
}
.quote-content-card .inline-char-avatar { width: 14px; height: 14px; }

/* 5. Meta Bar */
.quote-meta-bar {
  background: #F4F8FB; border: 1px solid #EDF0F6; border-radius: 6px;
  padding: 5px 9px; display: flex; justify-content: space-between; align-items: center;
}
.meta-bar-item {
  display: flex; align-items: center; gap: 4px; font-size: 10px; color: #868691;
}
.meta-bar-item svg { width: 10px; height: 10px; color: #B6B6BD; }
.meta-bar-dot {
  width: 2px; height: 2px; background: rgba(134, 134, 145, 0.4); border-radius: 50%;
}

/* (carousel indicators removed: mockup now uses scroll-to-preview) */

/* --- Screen 3: AI Writing Assistant --- */
.screen-ai-writing {
  background: var(--app-bg-primary);
  text-align: left;
}

.ai-writing-view {
  flex: 1;
  /* No top app bar: keep content below status bar/notch. */
  padding: 56px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.ai-writing-panel {
  background: var(--app-bg-card);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 14px;
  padding: 10px 10px 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.ai-writing-panel--draft {
  flex: 0 0 43%;
  display: flex;
  flex-direction: column;
}

.ai-writing-panel--polished {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  border-color: rgba(80, 125, 175, 0.22);
  background: linear-gradient(180deg, rgba(80, 125, 175, 0.08) 0%, #FFFFFF 46%);
}

.ai-writing-panel--combo {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-color: rgba(80, 125, 175, 0.18);
  background: var(--app-bg-card);
}

.ai-writing-segment {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ai-writing-segment--draft {
  flex: 0 0 auto;
  background: rgba(0, 0, 0, 0.018);
}
.ai-writing-segment--draft .ai-panel-header { margin-bottom: 6px; }
.ai-writing-segment--draft .ai-draft-title { margin-bottom: 4px; }

.ai-writing-divider {
  height: 1px;
  margin: 0 10px;
  background: rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.ai-writing-segment--polished {
  flex: 1 1 auto;
  min-height: 0;
  background: linear-gradient(180deg, rgba(80, 125, 175, 0.10) 0%, #FFFFFF 54%);
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-panel-title {
  font-size: 10px;
  color: var(--app-text-secondary);
  font-weight: 700;
  letter-spacing: 0.3px;
}

.ai-panel-hint {
  font-size: 10px;
  color: var(--app-text-tertiary);
  white-space: nowrap;
}

.ai-panel-badge {
  font-size: 10px;
  font-weight: 700;
  color: #507DAF;
  background: rgba(80, 125, 175, 0.10);
  border: 1px solid rgba(80, 125, 175, 0.18);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.ai-draft-text {
  flex: 1;
  min-height: 0;
}
.ai-draft-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--app-text-primary);
  margin-bottom: 6px;
}
.ai-draft-body {
  font-size: 12px;
  line-height: 1.45;
  color: var(--app-text-primary);
  overflow: hidden;
}
.ai-draft-body p { margin: 0 0 8px; }
.ai-draft-body p:last-child { margin-bottom: 0; }

.ai-polished-title {
  font-family: "Noto Serif SC", serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--app-text-primary);
  margin-bottom: 6px;
}
.ai-polished-meta {
  font-size: 10px;
  color: var(--app-text-secondary);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-polished-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.55;
  color: var(--app-text-primary);
  text-align: justify;
}
.ai-polished-body p { margin: 0 0 10px; }
.ai-polished-body p:last-child { margin-bottom: 0; }

/* --- Screen 4: AI Digital Avatar (Chat) --- */
.screen-ai-avatar {
  background: radial-gradient(circle at 50% 30%, #FDFBF7 0%, #F4F6F9 100%);
  position: relative;
  text-align: left;
  overflow: hidden;
}

/* Atmospheric Stardust */
.ai-bg-stardust {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background-image: 
    radial-gradient(1px 1px at 20% 30%, rgba(80, 125, 175, 0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 70%, rgba(80, 125, 175, 0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 40%, rgba(80, 125, 175, 0.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 80% 80%, rgba(255, 215, 0, 0.3) 0%, transparent 100%),
    radial-gradient(2px 2px at 10% 90%, rgba(255, 215, 0, 0.3) 0%, transparent 100%);
  background-size: 150% 150%;
  opacity: 0.6;
  animation: stardust-drift 20s infinite alternate ease-in-out;
  pointer-events: none;
  z-index: 0;
}

@keyframes stardust-drift {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-20px) scale(1.05); }
}

.ai-bg-glow {
  position: absolute;
  top: -10%; left: -10%; width: 120%; height: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(255, 215, 0, 0.06) 0%, transparent 100%);
  z-index: 0;
  pointer-events: none;
}

.ai-avatar-nav {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(0,0,0,0.02);
}

.mini-avatar-badge {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.mini-avatar-badge .mini-avatar { width: 100%; height: 100%; }

.ai-chat-avatar.is-ai,
.mini-avatar-badge.is-ai { position: relative; }

/* Refined AI Badge - Washed Azure */
.ai-chat-avatar.is-ai::after,
.mini-avatar-badge.is-ai::after {
  content: "AI";
  position: absolute;
  right: -3px;
  bottom: -3px;
  border-radius: 6px;
  background: linear-gradient(135deg, #8ABAF0 0%, #609CE1 100%);
  color: #FFF;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #FFF;
  box-shadow: 0 2px 6px rgba(96, 156, 225, 0.2);
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  z-index: 2;
}
.ai-chat-avatar.is-ai::after { width: 15px; height: 15px; font-size: 8px; border-radius: 50%; }
.mini-avatar-badge.is-ai::after { width: 10px; height: 10px; font-size: 6px; border-radius: 50%; }

.ai-avatar-nav-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.ai-avatar-nav-titles {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.ai-avatar-nav-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--app-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.ai-avatar-nav-sub {
  font-size: 10px;
  color: #889;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.ai-avatar-nav-more {
  font-size: 16px;
  line-height: 1;
  color: var(--app-text-tertiary);
  transform: translateY(-1px);
}

.ai-chat-view {
  flex: 1;
  padding: 10px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 16px; 
  overflow: hidden;
  text-align: left;
  z-index: 1; 
}

.ai-chat-date {
  align-self: center;
  font-size: 10px;
  color: #868691;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(0,0,0,0.02);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.ai-chat-row {
  display: flex;
  align-items: flex-start; 
  gap: 12px;
}
.ai-chat-row--me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.ai-chat-row--ai {
  align-self: flex-start;
}

/* Avatar Aura Animation - Lighter Blue */
.ai-avatar-aura {
  position: absolute;
  top: -4px; left: -4px; right: -4px; bottom: -4px;
  border-radius: 50%;
  border: 1px solid rgba(106, 181, 246, 0.3);
  border-top-color: rgba(255, 215, 0, 0.4);
  animation: avatar-spin 4s linear infinite;
  opacity: 0.6;
  pointer-events: none;
}
@keyframes avatar-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ai-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: visible;
  background: #FFF;
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  flex-shrink: 0;
  position: relative;
}
.ai-chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; position: relative; z-index: 1; }

.ai-chat-bubble {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
  text-align: left;
}

/* AI Bubble: The "Soul" Styling */
.ai-chat-bubble--ai {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 
    0 4px 16px rgba(50, 50, 93, 0.05),
    0 1px 3px rgba(0,0,0,0.02);
  color: #423E3E; /* Warmer "Ink" Color */
  border-radius: 4px 18px 18px 18px;
  font-family: "Noto Serif SC", serif;
  padding: 0; /* Reset padding for internal layout */
  overflow: hidden;
}

.ai-bubble-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 2px;
}

.ai-chat-ai-tag {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #868691;
  display: flex;
  align-items: center;
  line-height: 1;
  gap: 4px;
}
.ai-chat-ai-tag::before {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  background: linear-gradient(135deg, #8ABAF0 0%, #609CE1 100%);
  border-radius: 50%;
  /* 视觉对齐修正：极小字体下圆点需微向上移 */
  margin-top: -1px;
}

/* Voice Playback Button */
.ai-voice-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(229, 192, 121, 0.12);
  border: 1px solid rgba(229, 192, 121, 0.25);
  color: #B08D55;
  border-radius: 12px;
  padding: 3px 8px 3px 6px;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(229, 192, 121, 0.05);
}

.ai-voice-btn:hover {
  background: rgba(229, 192, 121, 0.2);
  transform: translateY(-1px);
}

.voice-icon {
  width: 10px;
  height: 10px;
  opacity: 0.9;
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 1.5px;
  height: 8px;
  margin-left: 2px;
}

.voice-wave i {
  width: 1.5px;
  height: 100%;
  background-color: #B08D55;
  border-radius: 1px;
  animation: voice-wave 1s ease-in-out infinite;
}

.voice-wave i:nth-child(1) { height: 40%; animation-delay: 0s; }
.voice-wave i:nth-child(2) { height: 100%; animation-delay: 0.2s; }
.voice-wave i:nth-child(3) { height: 60%; animation-delay: 0.4s; }

@keyframes voice-wave {
  0%, 100% { height: 40%; opacity: 0.8; }
  50% { height: 100%; opacity: 1; }
}

.ai-text-content {
  padding: 4px 14px 10px;
}

/* Memory Source Citation - Golden "Precious Memory" Theme */
.ai-memory-source {
  margin-top: 0;
  padding: 8px 14px;
  background: rgba(229, 192, 121, 0.08); /* Faint Gold */
  border-top: 1px solid rgba(229, 192, 121, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; /* Tech font */
  font-size: 10px;
  color: #B08D55; /* Muted Gold Text */
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-icon {
  font-size: 10px;
  color: #FFD700; /* Gold icon */
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.4);
}

/* User Bubble: "Washed Azure" - Gentle & Healing */
.ai-chat-bubble--me {
  background: linear-gradient(135deg, #8ABAF0 0%, #609CE1 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 6px 16px rgba(96, 156, 225, 0.2);
  font-weight: 500;
  letter-spacing: 0.2px;
}

.ai-chat-input-bar {
  padding: 10px 16px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,0.03);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

.ai-chat-input {
  flex: 1;
  height: 40px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 20px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #889;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
}
.ai-chat-input:hover {
  background: #FFF;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.ai-chat-send {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: #FFF;
  background: linear-gradient(135deg, #8ABAF0 0%, #609CE1 100%);
  padding: 9px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(96, 156, 225, 0.25);
}
