/* ============ 主题变量（梦幻紫 · 简洁专业） ============ */
:root {
  --bg: #f6f2ff;              /* 梦幻淡紫底 */
  --bg-chat: #f6f2ff;
  --card: #ffffff;
  --primary: #7c6cf0;
  --primary-deep: #5f4fe0;
  --primary-soft: #ede9ff;
  --accent: #b8a5ff;
  --ink: #2b2440;
  --muted: #9a94b0;
  --line: #ece7fb;
  --star: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --radius: 16px;
  --shadow-sm: 0 2px 8px rgba(124,108,240,0.07);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(170deg, #f5eeff 0%, #eef2ff 42%, #f9ecff 100%);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: transparent;
  padding-bottom: calc(56px + var(--safe-bottom));
}
#app.chat-open { padding-bottom: calc(56px + var(--safe-bottom)); height: 100vh; display: flex; flex-direction: column; }

/* ============ 顶部导航栏（微信式） ============ */
.navbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  height: 50px; padding: 0 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.navbar__title { font-size: 17px; font-weight: 600; }
.navbar__left { position: absolute; left: 8px; font-size: 24px; cursor: pointer; color: var(--ink); text-decoration: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.navbar__right { position: absolute; right: 12px; font-size: 22px; cursor: pointer; color: var(--primary-deep); width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* ============ 底部 Tabbar ============ */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + var(--safe-bottom)); z-index: 50;
}
.tabbar__item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; }
.tabbar__icon { font-size: 24px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.tabbar__icon svg { width: 24px; height: 24px; }
.chat-input__toggle svg { width: 22px; height: 22px; }
.chat-input__send svg { width: 20px; height: 20px; }
.navbar__right svg { width: 22px; height: 22px; }
.tabbar__item.is-active { color: var(--primary-deep); }
.tabbar__item.is-active .tabbar__icon { transform: scale(1.05); }

/* ============ 会话列表（类型列表，微信式） ============ */
.conv-list { background: var(--card); }
.conv-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  cursor: pointer; transition: background .12s;
}
.conv-item:active { background: #f2f2f6; }
.conv-item + .conv-item { border-top: 1px solid var(--line); }
.conv-item__avatar {
  width: 48px; height: 48px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: var(--primary-soft);
}
.conv-item__body { flex: 1; min-width: 0; }
.conv-item__top { display: flex; align-items: baseline; justify-content: space-between; }
.conv-item__name { font-size: 16px; font-weight: 500; }
.conv-item__time { font-size: 12px; color: var(--muted); flex: 0 0 auto; margin-left: 8px; }
.conv-item__preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.conv-item__empty { font-size: 13px; color: #b8b8c0; margin-top: 3px; }

/* ============ 聊天界面 ============ */
.chat-body {
  flex: 1; overflow-y: auto; padding: 16px 14px 12px;
  -webkit-overflow-scrolling: touch;
}
.msg { display: flex; margin-bottom: 14px; }
.msg--user { justify-content: flex-end; }
.msg--ai { justify-content: flex-start; }
.msg__avatar { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.msg--user .msg__avatar { display: none; }
.msg--ai .msg__avatar { background: var(--primary-soft); margin-right: 8px; }
.msg__content { max-width: 76%; }
.bubble {
  padding: 10px 13px; border-radius: 12px; font-size: 15px; word-break: break-word; white-space: pre-wrap;
}
.msg--user .bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.msg--ai .bubble { background: #fff; color: var(--ink); border-top-left-radius: 4px; box-shadow: var(--shadow-sm); }
.msg__symbols { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.msg--user .msg__symbols { justify-content: flex-end; }
.mini-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-deep);
}
.msg--user .mini-tag { background: rgba(255,255,255,0.22); color: #fff; }
.msg__meta { font-size: 11px; color: #b8b8c0; margin-top: 4px; }
.msg--user .msg__meta { text-align: right; }
.msg__hint { font-size: 11px; color: var(--muted); margin-top: 5px; cursor: pointer; }
.confirm-btns { display: flex; gap: 8px; margin-top: 10px; }
.confirm-btn { flex: 1; padding: 10px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; cursor: pointer; }
.confirm-btn--yes { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* 输入栏（微信式） */
.chat-input {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(8px + var(--safe-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.chat-input__voice {
  width: 38px; height: 38px; border: none; border-radius: 50%; background: var(--primary-soft);
  font-size: 20px; cursor: pointer; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.chat-input__voice.recording { background: var(--danger); animation: pulse 1.4s infinite; }
.chat-input__toggle {
  width: 38px; height: 38px; border: none; border-radius: 50%; background: var(--primary-soft);
  font-size: 20px; cursor: pointer; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
}
.chat-input__voice-bar {
  flex: 1; height: 38px; border: none; border-radius: 8px; background: var(--primary-soft);
  color: var(--primary-deep); font-size: 15px; font-weight: 500; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.chat-input__voice-bar.recording { background: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
.chat-input__box {
  flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  font-size: 15px; font-family: inherit; background: #f7f7fa; resize: none; outline: none;
  max-height: 120px;
}
.chat-input__box:focus { border-color: var(--accent); background: #fff; }
.chat-input__send {
  flex: 0 0 auto; border: none; border-radius: 50%; width: 40px; height: 40px;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-input__send:active { background: var(--primary-deep); }

@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(248,113,113,.4)} 50%{box-shadow:0 0 0 14px rgba(248,113,113,0)} }

/* ============ 档案（时间轴） ============ */
.timeline { padding: 12px 16px; }
.timeline__group { margin-bottom: 16px; }
.timeline__date { font-size: 13px; color: var(--muted); font-weight: 600; margin: 4px 2px 8px; }
.dream-item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 8px; cursor: pointer;
}
.dream-item:active { background: #f7f7fa; }
.dream-item__emoji { font-size: 24px; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); border-radius: 12px; flex: 0 0 auto; }
.dream-item__body { flex: 1; min-width: 0; }
.dream-item__text { font-size: 14px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dream-item__meta { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.dream-item__arrow { color: #c8c8d0; font-size: 18px; }

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty__emoji { font-size: 56px; }
.empty__text { font-size: 14px; margin-top: 10px; }

/* ============ 梦境详情（四段式） ============ */
.detail-head { text-align: center; padding: 24px 16px 8px; }
.detail-head__emoji { font-size: 48px; }
.detail-head__title { font-size: 19px; font-weight: 600; margin: 8px 0 2px; }
.detail-head__sub { font-size: 13px; color: var(--muted); }

.block { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 0 14px 10px; }
.block__tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--primary-deep); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.block__text { font-size: 15px; margin: 0; white-space: pre-wrap; }
.block__text--muted { color: var(--muted); font-size: 13px; }

.trace-item { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.trace-item:last-child { border-bottom: none; }
.trace-item__kw { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.trace-item__school { font-size: 11px; color: var(--primary-deep); background: var(--primary-soft); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.trace-item__def { font-size: 13px; color: var(--muted); margin-top: 5px; }

.feedback { display: flex; gap: 10px; margin: 4px 14px 16px; }
.feedback button { flex: 1; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 14px; cursor: pointer; }
.feedback button.is-on--yes { border-color: var(--ok); background: #ecfdf5; color: #059669; }
.feedback button.is-on--no { border-color: var(--danger); background: #fef2f2; color: #dc2626; }
.disclaimer { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 24px 16px; }

/* ============ 我的页 ============ */
.profile { display: flex; align-items: center; gap: 14px; padding: 20px 16px; background: var(--card); }
.profile__avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--primary)); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.profile__name { font-size: 18px; font-weight: 600; margin: 0; }
.profile__sub { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.menu { background: var(--card); margin-top: 12px; }
.menu__item { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px; }
.menu__item:last-child { border-bottom: none; }
.menu__item .arrow { color: #c8c8d0; }
.voice-list { background: var(--card); margin-top: 12px; }
.voice-item { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.voice-item:last-child { border-bottom: none; }
.voice-item.is-on { background: var(--primary-soft); }
.voice-item__name { font-size: 15px; }
.voice-item__preview { font-size: 13px; color: var(--primary-deep); background: var(--primary-soft); padding: 5px 12px; border-radius: 999px; cursor: pointer; }

/* ============ 通用 ============ */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(31,31,31,0.92); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 99; max-width: 80%; text-align: center;
}
.loading { position: fixed; inset: 0; background: rgba(237,237,242,0.96); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 98; }
.loading__spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .8s linear infinite; margin-bottom: 16px; }
.loading p { color: var(--primary-deep); font-size: 15px; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
