/* ===== 基础重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0d0d1a;
  --bg-secondary: #141428;
  --bg-card: rgba(30, 30, 60, 0.6);
  --bg-card-hover: rgba(40, 40, 75, 0.7);
  --text-primary: #e8e6f0;
  --text-secondary: #9a96b0;
  --text-muted: #6b6680;
  --accent-gold: #f0c850;
  --accent-gold-dim: rgba(240, 200, 80, 0.15);
  --accent-purple: #8b5cf6;
  --accent-purple-dim: rgba(139, 92, 246, 0.15);
  --accent-blue: #6366f1;
  --border-color: rgba(255, 255, 255, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
}

/* ===== 启动屏 ===== */
.splash {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: splashFadeOut 0.6s ease 1.5s forwards;
}

.splash-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 2s ease-in-out infinite;
}

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

.splash-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

@keyframes splashFadeOut {
  to { opacity: 0; pointer-events: none; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== 主容器 ===== */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(70px + var(--safe-bottom));
  min-height: 100vh;
}

.app.hidden {
  opacity: 0;
}

.app {
  animation: appFadeIn 0.5s ease 1.8s forwards;
  opacity: 0;
}

@keyframes appFadeIn {
  to { opacity: 1; }
}

/* ===== 顶部导航 ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 20px 12px;
  background: rgba(13, 13, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== 视图系统 ===== */
.view {
  display: none;
  padding: 16px 16px 24px;
  animation: viewIn 0.3s ease;
}

.view.active {
  display: block;
}

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

/* ===== 首页英雄区 ===== */
.home-hero {
  text-align: center;
  padding: 24px 0 8px;
}

.hero-moon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

.hero-text {
  font-size: 15px;
  color: var(--text-secondary);
}

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-label {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ===== 梦境输入 ===== */
.input-card {
  position: relative;
}

.dream-input {
  width: 100%;
  min-height: 120px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  resize: none;
  outline: none;
  font-family: var(--font-family);
  transition: border-color 0.3s ease;
}

.dream-input::placeholder {
  color: var(--text-muted);
}

.dream-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px var(--accent-purple-dim);
}

.input-counter {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin: 6px 0 14px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 28px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-family);
  white-space: nowrap;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.btn-primary:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-gold {
  width: 100%;
  background: linear-gradient(135deg, #f0c850, #e8a030);
  color: #1a1a3e;
  box-shadow: 0 4px 15px rgba(240, 200, 80, 0.3);
}

.btn-gold:active {
  transform: scale(0.97);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 12px 20px;
  font-size: 14px;
}

.btn-outline:active {
  background: rgba(255, 255, 255, 0.04);
}

.btn-sm {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent-purple);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--font-family);
}

.btn-icon {
  font-size: 18px;
}

/* ===== 热门标签 ===== */
.hot-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hot-tag {
  padding: 8px 14px;
  background: var(--accent-purple-dim);
  border-radius: 20px;
  font-size: 13px;
  color: var(--accent-purple);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid rgba(139, 92, 246, 0.15);
}

.hot-tag:active {
  transform: scale(0.95);
  background: rgba(139, 92, 246, 0.25);
}

/* ===== 状态卡片 ===== */
.status-card {
  background: var(--accent-gold-dim);
  border-color: rgba(240, 200, 80, 0.15);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.status-row + .status-row {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 6px;
  padding-top: 12px;
}

.status-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.status-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-gold);
}

/* ===== 结果页 ===== */
.result-header {
  margin-bottom: 8px;
}

.result-card {
  animation: cardIn 0.4s ease;
}

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

.result-dream-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.result-dream-content {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
}

.result-section-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  font-size: 20px;
}

.result-text {
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.deep-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.deep-tag {
  padding: 4px 10px;
  background: var(--accent-purple-dim);
  border-radius: 12px;
  font-size: 12px;
  color: var(--accent-purple);
}

/* ===== 深度锁定 ===== */
.deep-locked {
  text-align: center;
  padding: 24px 0;
}

.lock-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.lock-text {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
}

.lock-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.lock-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
}

.lock-hint a {
  color: var(--accent-purple);
  text-decoration: none;
}

/* ===== 加载动画 ===== */
.deep-loading {
  text-align: center;
  padding: 30px 0;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-text {
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ===== 结果操作 ===== */
.result-actions {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

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

/* ===== 页面标题 ===== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 8px 0;
}

/* ===== 历史列表 ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-item:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

.history-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.history-dream {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-type {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.history-type.basic {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-blue);
}

.history-type.deep {
  background: var(--accent-gold-dim);
  color: var(--accent-gold);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-sub {
  font-size: 13px;
  margin-top: 6px;
}

/* ===== 个人中心 ===== */
.profile-stats {
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.stat-item {
  flex: 1;
}

.stat-num {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-gold), #f0a030);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

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

/* ===== 兑换 ===== */
.redeem-box {
  display: flex;
  gap: 10px;
}

.redeem-input {
  flex: 1;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  font-family: var(--font-family);
}

.redeem-input:focus {
  border-color: var(--accent-purple);
}

.redeem-msg {
  margin-top: 10px;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.redeem-msg.success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.redeem-msg.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ===== FAQ ===== */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.faq-q {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.faq-a {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== 免责声明 ===== */
.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 16px 20px;
  line-height: 1.6;
}

.disclaimer-full {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

/* ===== 底部导航 ===== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13, 13, 26, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 200;
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

.tab-label {
  font-size: 11px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.tab-item.active .tab-label {
  color: var(--accent-purple);
  font-weight: 600;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(30, 30, 50, 0.95);
  color: var(--text-primary);
  padding: 14px 28px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  z-index: 9999;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.toast.hidden {
  display: none;
}

/* ===== 工具类 ===== */
.hidden {
  display: none !important;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* ===== 响应式 ===== */
@media (min-width: 480px) {
  .app {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tab-bar {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
  }
}
