/* ============================================
   暖光 · 组件样式
   碎片卡片、输入框、记忆卡片等核心组件
   ============================================ */

/* ── 光河：碎片卡片 ── */
.fragment-card {
  width: 100%;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8vh var(--spacing-page) 0;
  position: relative;
  cursor: default;
}

.fragment-card .card-body {
  width: 100%;
  max-width: var(--max-width-card);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-paragraph);
}

.fragment-card .fragment-text {
  font-size: var(--font-size-fragment);
  color: var(--color-text);
  line-height: var(--line-height-fragment);
  word-break: break-word;
}

.fragment-card .ai-response {
  font-size: var(--font-size-ai);
  color: var(--color-text-ai);
  line-height: var(--line-height-ai);
  font-style: normal;
}

.fragment-card .card-meta {
  font-size: var(--font-size-meta);
  color: var(--color-text-meta);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.fragment-card .light-count {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 卡片操作区 */
.fragment-card .card-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-action);
  margin-top: auto;
  width: 100%;
  max-width: var(--max-width-card);
  padding-bottom: 4px;
}

.card-actions .btn-send-light {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 16px;
  font-family: var(--font-stack);
  cursor: pointer;
  padding: 10px 20px;
  transition: background 0.2s ease, transform var(--duration-press) ease;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.card-actions .btn-send-light:active {
  background: var(--color-primary-ghost);
  transform: scale(0.95);
}

.card-actions .btn-send-light .light-icon {
  font-size: 18px;
}

.card-actions .btn-next {
  background: transparent;
  border: none;
  color: #5C4A3A;
  font-size: 15px;
  font-family: var(--font-stack);
  cursor: pointer;
  padding: 8px 20px;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.7;
}

.card-actions .btn-next:active {
  opacity: 1;
}

/* 卡片切换动画 */
.fragment-card-wrapper {
  width: 100%;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.fragment-card-enter {
  animation: cardEnter var(--duration-card-enter) var(--ease-out);
}

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

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

/* 每日上限提示 */
.daily-limit-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex: 1;
  padding: 60px var(--spacing-page);
  text-align: center;
}

.daily-limit-notice .limit-text {
  font-size: var(--font-size-fragment);
  color: var(--color-text);
  line-height: 1.8;
}

.daily-limit-notice .limit-sub {
  font-size: 14px;
  color: var(--color-text-meta);
  line-height: 1.7;
}

/* 传送门文案 */
.gateway-text {
  position: absolute;
  top: 24px;
  left: var(--spacing-page);
  font-size: 12px;
  color: var(--color-text-ai);
  font-weight: 500;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gateway-text.visible {
  opacity: 0.8;
}

/* ── 碎碎念：写页面 ── */
.write-page {
  padding: var(--spacing-page);
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.write-prompt {
  font-size: var(--font-size-fragment);
  color: var(--color-text);
  line-height: 1.8;
  text-align: center;
  padding: 40px 0 28px;
}

.write-input {
  width: 100%;
  min-height: 160px;
  background: var(--color-bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  padding: 20px;
  font-size: var(--font-size-body);
  font-family: var(--font-stack);
  color: var(--color-text);
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}

.write-input:focus {
  border-color: #D4C4B2;
}

.write-input::placeholder {
  color: var(--color-text-meta);
}

.write-visibility {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 4px 0;
}

.visibility-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.visibility-option .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--color-text-meta);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visibility-option.selected .dot {
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.visibility-option .dot::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.visibility-option.selected .dot::after {
  opacity: 1;
}

.visibility-option .vis-label {
  font-size: 14px;
  color: var(--color-text-meta);
}

.visibility-option.selected .vis-label {
  color: var(--color-primary);
}

/* AI回应展示 */
.ai-response-display {
  background: var(--color-bg-input);
  border-radius: var(--radius-input);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.ai-response-display .ai-response-text {
  font-size: var(--font-size-ai);
  color: var(--color-text-ai);
  line-height: var(--line-height-ai);
  text-align: center;
}

.ai-response-display .typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ai-response-display .typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--color-text-meta);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

.ai-response-display .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-response-display .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* ── 光匣 ── */
.lightbox-page {
  padding: 0 var(--spacing-page);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-block);
}

.lightbox-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-list);
}

.lightbox-section-title {
  font-size: 14px;
  color: var(--color-text-meta);
  font-weight: 400;
  padding-top: 8px;
}

.lightbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-bg-card);
  border-radius: 12px;
}

.lightbox-item .item-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.lightbox-item .item-content {
  flex: 1;
  min-width: 0;
}

.lightbox-item .item-text {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lightbox-item .item-time {
  font-size: 11px;
  color: var(--color-text-meta);
  margin-top: 2px;
}

.lightbox-item .item-from {
  font-size: 12px;
  color: var(--color-text-ai);
}

/* 镜像时刻入口卡片 */
.mirror-entry-card {
  background: linear-gradient(135deg, #F5EFE9, #F0E6DA);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
}

.mirror-entry-card:active {
  transform: scale(0.98);
}

.mirror-entry-card .mirror-icon {
  font-size: 32px;
}

.mirror-entry-card .mirror-title {
  font-size: 16px;
  color: var(--color-text);
  font-weight: 500;
}

.mirror-entry-card .mirror-desc {
  font-size: 13px;
  color: var(--color-text-ai);
  line-height: 1.6;
}

/* 被看见/看见了统计 */
.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.stat-card {
  flex: 1;
  background: var(--color-bg-card);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-card .stat-number {
  font-size: 28px;
  color: var(--color-text);
  font-weight: 400;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--color-text-meta);
  margin-top: 4px;
}

/* ── 我的 ── */
.profile-page {
  padding: 0 var(--spacing-page);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-block);
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg-card);
  border-radius: 16px;
  padding: 20px;
}

.streak-badge .streak-icon {
  font-size: 36px;
}

.streak-badge .streak-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.streak-badge .streak-days {
  font-size: 24px;
  color: var(--color-text);
  font-weight: 400;
  line-height: 1.2;
}

.streak-badge .streak-label {
  font-size: 12px;
  color: var(--color-text-meta);
}

/* 跨天记忆卡片 */
.memory-card {
  background: var(--color-bg-input);
  border-radius: var(--radius-memory);
  padding: 12px 16px;
  font-size: var(--font-size-memory);
  color: var(--color-text-memory);
  line-height: 1.7;
  font-style: italic;
}

.memory-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 报告卡片 */
.report-card {
  background: var(--color-bg-card);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
}

.report-card:active {
  transform: scale(0.98);
}

.report-card .report-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.report-card .report-title {
  font-size: 16px;
  color: var(--color-text);
}

.report-card .report-desc {
  font-size: 12px;
  color: var(--color-text-meta);
}

.report-card .report-arrow {
  font-size: 18px;
  color: var(--color-text-meta);
}

/* 菜单列表 */
.menu-list {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card);
  border-radius: 16px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border-nav);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
  font-size: 15px;
  color: var(--color-text);
}

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

.menu-item:active {
  background: var(--color-bg-input);
}

.menu-item .menu-arrow {
  color: var(--color-text-meta);
  font-size: 14px;
}

/* ── 镜像时刻弹窗 ── */
.mirror-modal .mirror-quote {
  background: var(--color-bg-input);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--color-text);
  line-height: 1.8;
  text-align: center;
  margin: 20px 0;
}

.mirror-modal .mirror-message {
  font-size: 14px;
  color: var(--color-text-ai);
  text-align: center;
  line-height: 1.7;
  margin-bottom: 8px;
}

.mirror-modal .mirror-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

/* ── 送光飞行动画 ── */
.light-fly {
  position: fixed;
  z-index: 300;
  font-size: 24px;
  pointer-events: none;
  animation: lightFly var(--duration-light-fly) var(--ease-out) forwards;
}

@keyframes lightFly {
  0% {
    opacity: 1;
    transform: scale(0.5) translateY(0);
  }
  40% {
    opacity: 1;
    transform: scale(1.2) translateY(-40px);
  }
  100% {
    opacity: 0;
    transform: scale(1.5) translateY(-120px);
  }
}

/* ── 匿名留言弹窗 ── */
.anonymous-message-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg-overlay);
  display: flex;
  align-items: flex-end;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.anonymous-message-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.anonymous-message-panel {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: var(--color-bg-card);
  border-radius: 20px 20px 0 0;
  padding: 24px var(--spacing-page) calc(var(--spacing-safe-bottom) + 20px);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease-out);
}

.anonymous-message-overlay.show .anonymous-message-panel {
  transform: translateY(0);
}

.anonymous-message-panel .panel-handle {
  width: 36px;
  height: 4px;
  background: #DDD;
  border-radius: 2px;
  margin: 0 auto 20px;
}

.anonymous-message-panel .panel-title {
  font-size: 16px;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 16px;
}

.anonymous-message-panel .message-input {
  width: 100%;
  min-height: 60px;
  max-height: 100px;
  background: var(--color-bg-input);
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--font-stack);
  color: var(--color-text);
  line-height: 1.6;
  resize: none;
  outline: none;
}

.anonymous-message-panel .message-input::placeholder {
  color: var(--color-text-meta);
}

.anonymous-message-panel .message-char-count {
  text-align: right;
  font-size: 11px;
  color: var(--color-text-meta);
  margin-top: 4px;
  margin-bottom: 16px;
}

.anonymous-message-panel .message-actions {
  display: flex;
  gap: 12px;
}

.anonymous-message-panel .message-actions .btn-ghost {
  flex: 1;
  font-size: 14px;
  padding: 10px;
}

.anonymous-message-panel .message-actions .btn-primary {
  flex: 1;
  font-size: 14px;
  padding: 10px;
}

/* ── 设置页面 ── */
.settings-page {
  padding: var(--spacing-page);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border-nav);
}

.setting-item .setting-label {
  font-size: 15px;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-item .setting-sublabel {
  font-size: 12px;
  color: var(--color-text-meta);
}

/* 开关样式 */
.toggle-switch {
  width: 48px;
  height: 28px;
  background: #DDD;
  border-radius: 14px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* ── 选择器 ── */
.select-dropdown {
  font-size: 14px;
  color: var(--color-primary);
  background: transparent;
  border: none;
  font-family: var(--font-stack);
  cursor: pointer;
  -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C48B5C' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

/* ── 进度指示器 ── */
.progress-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 16px 0 12px;
}

.progress-dot {
  width: 7px;
  height: 7px;
  background: #D5CFC8;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.progress-dot.active {
  background: var(--color-primary);
  width: 16px;
  border-radius: 3px;
}

/* ── 年龄入口（Onboarding） ── */
#screen-onboarding {
  opacity: 1;
  transition: opacity 0.4s ease;
}

.onboarding-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 40px var(--spacing-page);
}

.onboarding-content {
  text-align: center;
  width: 100%;
  max-width: 340px;
}

.onboarding-logo {
  font-size: 36px;
  color: var(--color-primary);
  font-weight: 300;
  letter-spacing: 8px;
  margin-bottom: 12px;
}

.onboarding-subtitle {
  font-size: 14px;
  color: var(--color-text-meta);
  margin-bottom: 40px;
}

.onboarding-divider {
  width: 40px;
  height: 1px;
  background: var(--color-border-nav);
  margin: 0 auto 32px;
}

.onboarding-question {
  font-size: var(--font-size-fragment);
  color: var(--color-text);
  margin-bottom: 8px;
}

.onboarding-desc {
  font-size: 13px;
  color: var(--color-text-ai);
  margin-bottom: 40px;
}

.age-options {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.age-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 20px;
  background: var(--color-bg-card);
  border: 1.5px solid var(--color-border-nav);
  border-radius: 16px;
  cursor: pointer;
  font-family: var(--font-stack);
  transition: all 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.age-card:hover, .age-card:active {
  border-color: var(--color-primary);
  background: rgba(196, 139, 92, 0.04);
}

.age-number {
  font-size: 24px;
  color: var(--color-text);
  font-weight: 300;
}

.age-label {
  font-size: 12px;
  color: var(--color-text-meta);
}

.age-card:active .age-number {
  color: var(--color-primary);
}

/* ── 底部安全区适配 ── */
/* 修复BUG #14：添加 constant() 后备兼容老iOS */
@supports (padding-bottom: constant(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(10px + constant(safe-area-inset-bottom));
  }
  .anonymous-message-panel {
    padding-bottom: calc(20px + constant(safe-area-inset-bottom));
  }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .anonymous-message-panel {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
