/* ============================================
 * style.css - 个人主页主样式表（完整增强版 v2）
 * 2026-06-14 v2: 安全配色、全端响应式优化、技能图标系统
 * ============================================ */

:root {
  --primary:#6366f1; --primary-dark:#4f46e5; --primary-light:#eef2ff;
  --text:#1f2937; --text-light:#6b7280; --bg:#fafafa; --bg-alt:#f3f4f6;
  --border:#e5e7eb; --shadow:0 4px 6px -1px rgba(0,0,0,0.06),0 2px 4px -2px rgba(0,0,0,0.06);
  --radius:16px; --max-width:920px;
  --card-bg:#fff; --hero-gradient:linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
}

[data-theme="dark"] {
  --primary:#818cf8; --primary-dark:#6366f1; --primary-light:#1e1b4b;
  --text:#e5e7eb; --text-light:#9ca3af; --bg:#0f1117; --bg-alt:#181b24;
  --border:#272a34; --shadow:0 4px 6px -1px rgba(0,0,0,0.4);
  --card-bg:#181b24; --hero-gradient:linear-gradient(135deg, #1e1b4b 0%, #0f1117 100%);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans SC",sans-serif;
  color:var(--text); background:var(--bg); line-height:1.7; scroll-behavior:smooth;
  transition:background 0.3s,color 0.3s;
  -webkit-text-size-adjust:100%;
}

.container { max-width:var(--max-width); margin:0 auto; padding:0 20px; }
a { color:var(--primary); text-decoration:none; transition:color 0.2s; }
a:hover { color:var(--primary-dark); }

/* 暗色模式切换 */
.theme-toggle {
  position:fixed; top:16px; right:24px; z-index:1100; width:40px; height:40px;
  border-radius:50%; background:var(--card-bg); border:1px solid var(--border);
  cursor:pointer; font-size:1.2rem; display:flex; align-items:center; justify-content:center;
  box-shadow:var(--shadow); transition:all 0.2s;
}
.theme-toggle:hover { transform:scale(1.1); }
@media (max-width:640px) {
  .theme-toggle { top:12px; right:12px; width:36px; height:36px; font-size:1rem; }
}

/* 页头 */
.hero {
  background:var(--hero-gradient); color:#fff; text-align:center; position:relative; overflow:hidden;
  padding:80px 20px 60px; transition:background 0.3s;
}
.hero:before {
  content:''; position:absolute; inset:0;
  background:radial-gradient(ellipse 60% 50% at 50% 0%, rgba(255,255,255,0.08), transparent);
  pointer-events:none;
}
.hero h1 { font-size:2.8rem; font-weight:700; margin-bottom:10px; letter-spacing:-0.5px; }
.hero-title { font-size:1.2rem; opacity:0.9; font-weight:400; margin-bottom:8px; }
.hero-motto { font-size:1rem; opacity:0.8; min-height:24px; margin-top:8px; }
.typing-cursor { animation:blink 1s infinite; font-weight:300; }
@keyframes blink { 0%,100%{ opacity:0; } 50%{ opacity:1; } }

.avatar-wrapper { margin-bottom:16px; }
.avatar-img { width:100px; height:100px; border-radius:50%; border:4px solid rgba(255,255,255,0.4); object-fit:cover; }

/* 导航栏 */
.navbar { background:var(--card-bg); border-bottom:1px solid var(--border); position:sticky; top:0; z-index:100; box-shadow:0 1px 3px rgba(0,0,0,0.05); }
.navbar .container { display:flex; justify-content:center; gap:24px; flex-wrap:wrap; padding:0 20px; }
.navbar a { display:inline-block; padding:16px 0; color:var(--text-light); font-weight:500; border-bottom:2px solid transparent; transition:all 0.2s; font-size:0.9rem; white-space:nowrap; }
.navbar a:hover { color:var(--primary); border-bottom-color:var(--primary); }

/* 移动端导航：滚动式横排 */
@media (max-width:640px) {
  .navbar .container { gap:0; justify-content:flex-start; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
  .navbar .container::-webkit-scrollbar { display:none; }
  .navbar a { padding:14px 12px; font-size:0.82rem; flex-shrink:0; }
}

/* 通用 */
.section { padding:64px 0; }
.section-alt { background:var(--bg-alt); }
@media (max-width:640px) { .section { padding:40px 0; } }

.section-title { font-size:1.6rem; font-weight:600; margin-bottom:32px; position:relative; display:inline-block; }
.section-title::after { content:''; position:absolute; bottom:-6px; left:0; width:48px; height:3px; background:var(--primary); border-radius:2px; }
.bio-text { font-size:1.1rem; color:var(--text-light); max-width:680px; line-height:1.9; }
.empty-hint { color:var(--text-light); font-style:italic; padding:16px 0; }

/* 滚动动效 */
.fade-in { opacity:0; transform:translateY(20px); transition:opacity 0.6s ease,transform 0.6s ease; }
.fade-in.visible { opacity:1; transform:translateY(0); }
.highlight-pulse { animation:highlightPulse 1s ease 2; }
@keyframes highlightPulse { 0%,100%{box-shadow:var(--shadow)} 50%{box-shadow:0 0 0 6px rgba(37,99,235,0.3)} }

/* ==================== 技能卡片（智能图标系统） ==================== */
.skills-grid { display:flex; flex-wrap:wrap; gap:16px; }
@media (max-width:640px) { .skills-grid { gap:10px; } }

.skill-card {
  background:var(--card-bg); border:1px solid var(--border); border-radius:var(--radius);
  padding:20px 24px; min-width:140px; text-align:center; box-shadow:var(--shadow);
  transition:transform 0.2s,box-shadow 0.2s; cursor:default;
}
.skill-card:hover { transform:translateY(-2px); box-shadow:0 10px 25px -5px rgba(0,0,0,0.1); }
@media (max-width:640px) { .skill-card { min-width:calc(50% - 8px); padding:14px 12px; } }

.skill-icon { font-size:2rem; display:block; margin-bottom:6px; line-height:1; }
@media (max-width:640px) { .skill-icon { font-size:1.5rem; } }

.skill-name { font-weight:600; font-size:1.05rem; margin-bottom:8px; }
@media (max-width:640px) { .skill-name { font-size:0.9rem; } }

/* 进度条颜色跟随技能类型 */
.skill-bar-bg { background:var(--border); border-radius:10px; height:8px; overflow:hidden; }
.skill-bar-fill { height:100%; border-radius:10px; width:0%; transition:width 1s ease; }
.skill-card.visible .skill-bar-fill { width:var(--bar-width, 0%); }
.skill-bar-fill.color-frontend { background:linear-gradient(90deg,#f59e0b,#fbbf24); }
.skill-bar-fill.color-backend { background:linear-gradient(90deg,#10b981,#34d399); }
.skill-bar-fill.color-devops { background:linear-gradient(90deg,#6366f1,#818cf8); }
.skill-bar-fill.color-language { background:linear-gradient(90deg,#ec4899,#f472b6); }
.skill-bar-fill.color-data { background:linear-gradient(90deg,#14b8a6,#2dd4bf); }
.skill-bar-fill.color-design { background:linear-gradient(90deg,#8b5cf6,#a78bfa); }
.skill-bar-fill.color-soft { background:linear-gradient(90deg,#06b6d4,#22d3ee); }
.skill-bar-fill.color-other { background:linear-gradient(90deg,var(--primary),var(--primary-dark)); }
.skill-pct { font-size:0.8rem; color:var(--text-light); margin-top:4px; }

/* ==================== 时间线（增强版 v3） ==================== */
.timeline {
  position: relative;
  padding-left: 40px;
}

/* 中央竖线 */
.timeline::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(to bottom, var(--primary), var(--primary-light), var(--border));
  border-radius: 2px;
}

/* ===== 时间线条目 ===== */
.timeline-item {
  position: relative;
  margin-bottom: 36px;
  /* 滚动动画初始状态：隐藏 + 向上偏移 */
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.3s ease;
}
.timeline-item:last-child {
  margin-bottom: 0;
}

/* IntersectionObserver 触发后显示 */
.timeline-item.tl-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 图标圆点 */
.tl-dot {
  position: absolute;
  left: -32px;       /* 竖线在 19px，圆点中心对齐，19 - 16 = 3 ≈ 竖线左侧 */
  top: 8px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  z-index: 2;
  box-shadow: 0 0 0 4px var(--bg), 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* ===== 时间线卡片 ===== */
.tl-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

/* 悬停效果：卡片轻微左移 + 阴影加深 */
.tl-card:hover {
  transform: translateX(6px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}
/* 触摸设备不做位移动画，改为缩放反馈 */
@media (hover: none) and (pointer: coarse) {
  .tl-card:hover { transform: none; }
  .tl-card:active { transform: scale(0.98); }
}

/* 日期标签 */
.tl-date {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.82rem;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* 相对时间提示（"X年前"） */
.tl-relative {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--text-light);
  margin-left: 6px;
  font-weight: 400;
  opacity: 0.75;
}

/* 卡片标题 */
.tl-card h4 {
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--text);
  font-weight: 600;
}

/* 副标题 */
.tl-sub {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

/* 描述 */
.tl-desc {
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-top: 6px;
}

/* ===== 时间线类型图标颜色（可选增强） ===== */
.tl-dot.type-work       { border-color: #3b82f6; background: #eff6ff; }
.tl-dot.type-education  { border-color: #10b981; background: #ecfdf5; }
.tl-dot.type-project    { border-color: #f59e0b; background: #fffbeb; }
.tl-dot.type-milestone  { border-color: #8b5cf6; background: #f5f3ff; }

[data-theme="dark"] .tl-dot.type-work       { background: #1e3a5f; }
[data-theme="dark"] .tl-dot.type-education  { background: #064e3b; }
[data-theme="dark"] .tl-dot.type-project    { background: #78350f; }
[data-theme="dark"] .tl-dot.type-milestone  { background: #3b1f6e; }

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .timeline {
    padding-left: 0;  /* 去掉左侧竖线区域 */
  }

  /* 移动端隐藏竖线，改用卡片左侧小色条 */
  .timeline::before {
    display: none;
  }

  .timeline-item {
    margin-bottom: 24px;
    padding-left: 0;
    transform: translateY(20px); /* 减小动画偏移 */
  }

  /* 图标移到卡片内部左上角 */
  .tl-dot {
    position: absolute;
    left: 10px;
    top: -16px;  /* 半个圆露出卡片上方 */
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-width: 2px;
    box-shadow: 0 0 0 3px var(--bg);
    z-index: 2;
  }

  .tl-card {
    padding: 18px 14px 14px;
    border-left: 3px solid var(--primary);  /* 竖线变卡片左边框 */
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  .tl-card:hover {
    transform: none; /* 移动端不做左移 */
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  }

  .tl-card h4 {
    font-size: 1rem;
  }

  .tl-date {
    font-size: 0.75rem;
    padding: 2px 10px;
  }

  .tl-sub, .tl-desc {
    font-size: 0.82rem;
  }

  /* 确保图标内容不重叠 */
  .tl-card h4 {
    margin-top: 4px;
  }
}

/* 小屏手机额外收紧 */
@media (max-width: 480px) {
  .timeline-item {
    margin-bottom: 20px;
  }

  .tl-dot {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
    top: -14px;
    left: 8px;
  }

  .tl-card {
    padding: 16px 12px 12px;
  }

  .tl-date {
    font-size: 0.7rem;
    padding: 2px 8px;
  }

  .tl-card h4 {
    font-size: 0.9rem;
  }
}

/* ==================== 项目筛选栏 ==================== */
.filter-bar { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:24px; }
.filter-tag {
  padding:6px 16px; border-radius:20px; border:1px solid var(--border);
  background:var(--card-bg); color:var(--text-light); cursor:pointer;
  font-size:0.85rem; transition:all 0.2s;
  -webkit-tap-highlight-color:transparent; user-select:none;
}
.filter-tag:hover { border-color:var(--primary); color:var(--primary); }
.filter-tag.active { background:var(--primary); color:#fff; border-color:var(--primary); }

/* 项目卡片 */
.projects-grid { display:flex; flex-direction:column; gap:24px; }
.project-card {
  background:var(--card-bg); border:1px solid var(--border); border-radius:var(--radius);
  padding:28px; box-shadow:var(--shadow); transition:transform 0.2s,box-shadow 0.2s;
}
@media (max-width:640px) { .project-card { padding:18px; } }
.project-card:hover { transform:translateY(-2px); box-shadow:0 10px 25px -5px rgba(0,0,0,0.1); }
.project-thumb { margin-bottom:16px; border-radius:var(--radius); overflow:hidden; }
.project-thumb img { width:100%; max-height:220px; object-fit:cover; border-radius:var(--radius); }
.project-name { font-size:1.2rem; font-weight:600; margin-bottom:8px; color:var(--text); }
.project-desc { color:var(--text-light); margin-bottom:12px; line-height:1.7; }
.project-tech { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.tech-tag { background:var(--primary-light); color:var(--primary); font-size:0.8rem; padding:3px 10px; border-radius:20px; font-weight:500; }
.project-link { font-size:0.9rem; font-weight:500; }

/* ==================== 留言板 ==================== */
.guestbook-form-wrapper { margin-bottom:32px; }
.guestbook-form { background:var(--card-bg); border:1px solid var(--border); border-radius:var(--radius); padding:24px; box-shadow:var(--shadow); }
@media (max-width:640px) { .guestbook-form { padding:16px; } }
.form-row-2 { display:flex; gap:12px; margin-bottom:12px; }
@media (max-width:500px) { .form-row-2 { flex-direction:column; gap:8px; } }
.form-group-sm { margin-bottom:12px; }
.form-group-sm input, .form-group-sm textarea {
  width:100%; padding:10px 14px; border:1px solid var(--border); border-radius:var(--radius);
  font-size:0.9rem; font-family:inherit; outline:none; background:var(--bg); color:var(--text);
  transition:border-color 0.2s;
}
.form-group-sm input:focus, .form-group-sm textarea:focus { border-color:var(--primary); }
.form-group-sm textarea { resize:vertical; min-height:70px; }
.gb-form-footer { display:flex; justify-content:space-between; align-items:center; }
.char-count { font-size:0.8rem; color:var(--text-light); }

.guestbook-list { display:flex; flex-direction:column; gap:16px; }
.gb-item { background:var(--card-bg); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow); }
@media (max-width:640px) { .gb-item { padding:14px; } }
.gb-item-header { display:flex; align-items:center; gap:10px; margin-bottom:8px; flex-wrap:wrap; }
.gb-avatar { width:32px; height:32px; border-radius:50%; background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size:0.9rem; flex-shrink:0; }
.gb-item-header strong { font-size:0.95rem; }
.gb-time { margin-left:auto; font-size:0.8rem; color:var(--text-light); }
.gb-content { color:var(--text); font-size:0.95rem; line-height:1.6; word-break:break-word; }

/* ==================== GitHub 动态 ==================== */
.github-commits { display:flex; flex-direction:column; gap:12px; }
.gh-event { display:flex; align-items:flex-start; gap:12px; padding:12px 16px; background:var(--card-bg); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); }
@media (max-width:640px) { .gh-event { padding:10px 12px; } }
.gh-icon { font-size:1.3rem; flex-shrink:0; margin-top:2px; }
.gh-body { font-size:0.9rem; color:var(--text); word-break:break-word; }
.gh-time { font-size:0.8rem; color:var(--text-light); }

/* ==================== 联系方式 ==================== */
.contact-list { display:flex; flex-wrap:wrap; gap:20px; }
@media (max-width:640px) { .contact-list { flex-direction:column; gap:12px; } }
.contact-item {
  display:flex; align-items:center; gap:10px; background:var(--card-bg);
  border:1px solid var(--border); border-radius:var(--radius); padding:14px 22px;
  box-shadow:var(--shadow); transition:transform 0.2s;
}
@media (max-width:640px) { .contact-item { padding:12px 16px; } }
.contact-item:hover { transform:translateY(-2px); }
.contact-icon { font-size:1.4rem; }
.contact-label { font-weight:600; font-size:0.85rem; color:var(--text-light); }
.contact-value { color:var(--primary); font-weight:500; word-break:break-all; }

/* ==================== 页脚 ==================== */
.footer { background:#111827; color:#9ca3af; text-align:center; padding:32px 0; font-size:0.9rem; }
[data-theme="dark"] .footer { background:#000; }
.footer-stats { display:flex; justify-content:center; gap:24px; margin-bottom:12px; flex-wrap:wrap; }
@media (max-width:400px) { .footer-stats { gap:12px; } }
.footer-stats span { font-size:0.85rem; }
.footer-stats strong { color:#fff; margin-left:4px; }
[data-theme="dark"] .footer-stats strong { color:#e5e7eb; }

/* ==================== 按钮 ==================== */
.btn { display:inline-flex; align-items:center; justify-content:center; padding:10px 20px; font-size:0.9rem; font-weight:500; border-radius:var(--radius); border:1px solid transparent; cursor:pointer; transition:all 0.2s; font-family:inherit; gap:6px; -webkit-tap-highlight-color:transparent; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-sm { padding:6px 14px; font-size:0.8rem; }
.btn:disabled { opacity:0.6; cursor:not-allowed; }

/* ==================== AI 聊天浮窗（Glassmorphism 现代风格） ==================== */
.chat-widget {
  position:fixed; bottom:24px; right:24px; z-index:1000;
  /* 防止移动端双击缩放并消除 300ms 点击延迟 */
  touch-action: manipulation;
  /* 让按钮在 iOS 刘海/底部条等安全区内布局（不贴着边缘） */
  padding-bottom: env(safe-area-inset-bottom);
  padding-right:  env(safe-area-inset-right);
}
@media (max-width:640px) {
  .chat-widget { bottom:14px; right:10px; }
}

/* ===== AI 图标浮窗按钮（圆角玻璃卡片） ===== */
.chat-toggle {
  width:68px; height:68px; border-radius:20px;
  background:linear-gradient(135deg,
    rgba(99,102,241,0.85) 0%,
    rgba(139,92,246,0.85) 50%,
    rgba(59,130,246,0.85) 100%);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
  border:2px solid rgba(255,255,255,0.25);
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:
    0 4px 16px rgba(0,0,0,0.2),
    0 8px 32px rgba(99,102,241,0.35),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transition:all 0.35s cubic-bezier(0.34,1.56,0.64,1);
  position:relative; overflow:visible; padding:0;
  -webkit-tap-highlight-color:transparent;
  touch-action: manipulation;
  user-select:none; -webkit-user-select:none;
}
/* 外层光晕呼吸 */
.chat-toggle::before {
  content:''; position:absolute; inset:-6px; border-radius:24px;
  background:linear-gradient(135deg,
    rgba(99,102,241,0.3),
    rgba(139,92,246,0.25),
    rgba(59,130,246,0.3));
  z-index:-1; opacity:0.5;
  animation:glowBreathe 3s ease-in-out infinite;
}
@keyframes glowBreathe {
  0%,100%{ opacity:0.4; transform:scale(1); }
  50%{ opacity:0.75; transform:scale(1.08); }
}
@media (max-width:640px) {
  .chat-toggle { width:58px; height:58px; border-radius:18px; }
  .chat-toggle::before { border-radius:22px; }
}

/* AI 图标 SVG 缩放：viewBox 64x64 */
.chat-toggle .ai-icon {
  width:42px; height:42px;
  filter:drop-shadow(0 2px 6px rgba(0,0,0,0.25));
  transition:filter 0.3s, transform 0.3s;
}
@media (max-width:640px) {
  .chat-toggle .ai-icon { width:36px; height:36px; }
}

/* 泡内三点呼吸动画 */
.chat-toggle .dot {
  animation:dotPulse 1.4s ease-in-out infinite;
  transform-origin: center;
}
.chat-toggle .dot2 { animation-delay:0.2s; }
.chat-toggle .dot3 { animation-delay:0.4s; }
@keyframes dotPulse {
  0%, 100% { opacity:0.5; transform:translateY(0); }
  50%      { opacity:1;   transform:translateY(-2px); }
}

/* 闪光星点闪烁 */
.chat-toggle .spark {
  animation:sparkTwinkle 2.2s ease-in-out infinite;
  transform-origin: center;
}
.chat-toggle .spark2 { animation-delay:0.7s; }
@keyframes sparkTwinkle {
  0%, 100% { opacity:0.35; transform:scale(0.85); }
  50%      { opacity:1;    transform:scale(1.1); }
}

/* 悬停 */
.chat-toggle:hover {
  transform:translateY(-6px) scale(1.06);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.3),
    0 12px 40px rgba(99,102,241,0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
  border-color:rgba(129,140,248,0.5);
}
.chat-toggle:hover .ai-icon {
  filter:drop-shadow(0 2px 12px rgba(255,255,255,0.5));
}
/* 悬停抖动 + AI 闪光加速 */
.chat-toggle:hover .ai-icon {
  animation:iconWiggle 0.7s ease-in-out;
}
.chat-toggle:hover .spark { animation-duration:0.9s; }
@keyframes iconWiggle {
  0%,100%{ transform:scale(1) rotate(0deg); }
  30%   { transform:scale(1.08) rotate(-4deg); }
  70%   { transform:scale(1.08) rotate(4deg); }
}

/* 悬停提示文字 */
.avatar-tooltip {
  position:absolute; bottom:-32px; left:50%; transform:translateX(-50%);
  background:rgba(30,30,40,0.92); color:#e5e7eb; font-size:0.72rem;
  padding:5px 14px; border-radius:14px; white-space:nowrap;
  border:1px solid rgba(255,255,255,0.15);
  backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
  opacity:0; transition:opacity 0.25s,transform 0.25s;
  font-family:inherit; font-weight:500;
  transform:translateX(-50%) translateY(4px);
}
.chat-toggle:hover .avatar-tooltip {
  opacity:1;
  transform:translateX(-50%) translateY(0);
}
@media (max-width:640px) { .avatar-tooltip { bottom:-26px; font-size:0.68rem; } }

/* 未读红点（克制版：小型胶囊，无外圈，轻微浮动） */
.chat-unread {
  position:absolute; top:-3px; left:-3px;
  min-width:16px; height:16px; padding:0 4px;
  border-radius:9px; background:#EF4444;
  color:#fff; font-size:0.64rem; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  box-shadow:
    0 1px 3px rgba(0,0,0,0.2),
    0 0 0 1px rgba(255,255,255,0.9) inset,
    0 0 8px rgba(239,68,68,0.45);
  font-family:inherit; line-height:1;
  animation:unreadIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events:none;
  letter-spacing:-0.02em;
}
@keyframes unreadIn {
  from { opacity:0; transform:scale(0.3); }
  to   { opacity:1; transform:scale(1); }
}

/* 收到回复时的按钮脉冲 */
.chat-toggle.bump {
  animation:btnBump 0.7s cubic-bezier(0.34,1.56,0.64,1);
}
.chat-toggle.bump .ai-icon { animation:iconBump 0.7s ease-out; }
@keyframes btnBump {
  0%   { transform:translateY(0) scale(1); }
  30%  { transform:translateY(-6px) scale(1.08); }
  60%  { transform:translateY(-2px) scale(1.04); }
  100% { transform:translateY(0) scale(1); }
}
@keyframes iconBump {
  0%   { filter:drop-shadow(0 2px 6px rgba(0,0,0,0.25)) brightness(1); }
  35%  { filter:drop-shadow(0 4px 14px rgba(255,255,255,0.6)) brightness(1.25); }
  100% { filter:drop-shadow(0 2px 6px rgba(0,0,0,0.25)) brightness(1); }
}

/* ===== 消息流内的常见问题 chip ===== */
.msg-quick-questions {
  display:flex; flex-wrap:wrap; gap:6px; margin-top:8px;
}
.msg-quick {
  font-family:inherit; font-size:0.78rem;
  padding:6px 12px; border-radius:14px;
  background:rgba(99,102,241,0.08);
  color:#6366F1;
  border:1px solid rgba(99,102,241,0.18);
  cursor:pointer;
  transition:all 0.2s ease;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  white-space:nowrap;
  line-height:1.3;
}
[data-theme="dark"] .msg-quick {
  background:rgba(129,140,248,0.12);
  color:#A5B4FC;
  border-color:rgba(129,140,248,0.25);
}
.msg-quick:hover {
  background:linear-gradient(135deg, #6366f1, #8b5cf6);
  color:#fff;
  border-color:transparent;
  transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(99,102,241,0.3);
}
.msg-quick:active { transform:scale(0.96); }
@media (max-width:640px) {
  .msg-quick { font-size:0.74rem; padding:5px 10px; }
}

/* ===== 聊天面板 ===== */
.chat-panel {
  width:400px; max-height:580px;
  background:rgba(255,255,255,0.82);
  border-radius:20px;
  border:1px solid rgba(255,255,255,0.3);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.12),
    0 2px 8px rgba(0,0,0,0.06),
    0 0 0 1px rgba(255,255,255,0.15) inset;
  display:flex; flex-direction:column;
  overflow:hidden;
  backdrop-filter:blur(24px); -webkit-backdrop-filter:blur(24px);
  animation:chatSlideIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
[data-theme="dark"] .chat-panel {
  background:rgba(20,24,35,0.88);
  border:1px solid rgba(255,255,255,0.08);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.04) inset;
}
@media (max-width:640px) {
  .chat-panel {
    width: calc(100vw - 16px);
    max-height: min(80vh, calc(100dvh - 60px - env(safe-area-inset-bottom, 0px)));
    border-radius: 18px;
    /* 避免聊天面板随键盘弹起被遮：dvh 单位跟随可视高度而非布局高度 */
  }
  /* 输入区不被虚拟键盘挤压 */
  .chat-input-area {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  /* 浮窗按钮在小屏避开手势条往里缩 */
  .chat-widget { bottom: 14px; right: 10px; }
  .chat-toggle { width: 56px; height: 56px; border-radius: 18px; }
  .chat-toggle::before { border-radius: 20px; }
  .chat-toggle .ai-icon { width: 34px; height: 34px; }
}
@keyframes chatSlideIn {
  from{opacity:0;transform:translateY(16px) scale(0.96)}
  to{opacity:1;transform:translateY(0) scale(1)}
}

/* 聊天头部（渐变） */
.chat-header {
  background:linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  color:#fff; padding:14px 18px;
  display:flex; justify-content:space-between; align-items:center;
  font-weight:600; font-size:0.95rem;
  box-shadow:0 2px 12px rgba(99,102,241,0.2);
  position:relative; z-index:1;
}
.chat-header-left { display:flex; align-items:center; gap:10px; }
.chat-header-left svg { filter:drop-shadow(0 1px 3px rgba(0,0,0,0.25)); }
.chat-header-left .ai-icon-mini { animation:miniIconFloat 3s ease-in-out infinite; }
@keyframes miniIconFloat {
  0%,100% { transform:translateY(0); }
  50%     { transform:translateY(-1px); }
}
.chat-header-right { display:flex; align-items:center; gap:2px; }
.chat-close,.chat-clear {
  background:rgba(255,255,255,0.12); border:none; color:#fff;
  cursor:pointer; font-size:0.9rem; padding:6px 12px;
  transition:all 0.2s; border-radius:8px; font-family:inherit;
  backdrop-filter:blur(4px);
}
.chat-close:hover,.chat-clear:hover {
  background:rgba(255,255,255,0.25);
  transform:scale(1.05);
}
.chat-clear { font-size:0.82rem; }

/* 消息区 */
.chat-messages {
  flex:1; overflow-y:auto; padding:18px;
  display:flex; flex-direction:column; gap:14px;
  max-height:370px; background:rgba(248,250,252,0.5);
  -webkit-overflow-scrolling:touch;
  scroll-behavior:smooth;
}
[data-theme="dark"] .chat-messages {
  background:rgba(10,12,18,0.3);
}
@media (max-width:640px) { .chat-messages { max-height:48vh; padding:14px; } }

/* 消息行 */
.chat-msg {
  display:flex;
  animation:msgPopIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes msgPopIn {
  from{opacity:0;transform:translateY(8px) scale(0.96)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
.chat-msg.user { justify-content:flex-end; }
.msg-bubble { max-width:82%; display:flex; flex-direction:column; gap:3px; }

/* 对话框 */
.msg-content {
  padding:11px 16px; border-radius:18px;
  font-size:0.9rem; line-height:1.55; word-break:break-word;
}
/* 用户气泡：渐变 */
.chat-msg.user .msg-content {
  background:linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color:#fff;
  border-bottom-right-radius:6px;
  box-shadow:0 2px 12px rgba(99,102,241,0.25);
}
/* AI 气泡：毛玻璃 */
.chat-msg.assistant .msg-content {
  background:rgba(255,255,255,0.7);
  color:var(--text);
  border:1px solid rgba(0,0,0,0.06);
  border-bottom-left-radius:6px;
  backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
  box-shadow:0 1px 6px rgba(0,0,0,0.04);
}
[data-theme="dark"] .chat-msg.assistant .msg-content {
  background:rgba(40,45,60,0.7);
  border:1px solid rgba(255,255,255,0.08);
}

.msg-time { font-size:0.68rem; color:var(--text-light); padding:0 8px; opacity:0.7; }
.chat-msg.user .msg-time { text-align:right; }

/* AI 引用 */
.msg-refs { margin-top:8px; display:flex; flex-wrap:wrap; gap:6px; }
.msg-ref-link {
  display:inline-block; font-size:0.78rem;
  color:var(--primary);
  background:rgba(99,102,241,0.08);
  padding:4px 12px; border-radius:14px;
  text-decoration:none; transition:all 0.2s;
  border:1px solid rgba(99,102,241,0.15);
}
.msg-ref-link:hover {
  background:linear-gradient(135deg, #6366f1, #8b5cf6);
  color:#fff;
  border-color:transparent;
}

/* AI 聊天消息内链接（URL/邮箱自动转可点击） */
.msg-content .msg-link {
  color:#4F46E5;
  text-decoration:underline;
  text-underline-offset:2px;
  transition:all 0.15s;
  word-break:break-all;
}
.msg-content .msg-link:hover {
  color:#6366F1;
  background:rgba(99,102,241,0.12);
  border-radius:3px;
}
[data-theme="dark"] .msg-content .msg-link {
  color:#A5B4FC;
}

/* 错误消息 */
.msg-bubble-error .msg-content {
  background:rgba(254,226,226,0.85)!important;
  border:1px solid rgba(239,68,68,0.2)!important;
  color:#991b1b!important;
  backdrop-filter:blur(8px);
}
[data-theme="dark"] .msg-bubble-error .msg-content {
  background:rgba(69,10,10,0.7)!important;
  border:1px solid rgba(239,68,68,0.2)!important;
  color:#fca5a5!important;
}
.msg-retry-btn {
  margin:6px 0 0 8px; padding:5px 14px; font-size:0.75rem;
  background:linear-gradient(135deg, #6366f1, #8b5cf6);
  color:#fff; border:none; border-radius:12px;
  cursor:pointer; transition:all 0.2s; align-self:flex-start;
  font-family:inherit; box-shadow:0 2px 8px rgba(99,102,241,0.2);
}
.msg-retry-btn:hover {
  transform:scale(1.05);
  box-shadow:0 4px 14px rgba(99,102,241,0.3);
}

/* 加载动画 */


/* ===== 流式打字光标 ===== */
.streaming-cursor {
  display:inline-block;
  width:2px; height:1em;
  margin-left:2px;
  background:var(--primary);
  vertical-align:text-bottom;
  animation:cursorBlink 0.9s steps(1, end) infinite;
}
@keyframes cursorBlink {
  0%, 50%  { opacity:1; }
  51%,100% { opacity:0; }
}
[data-theme="dark"] .streaming-cursor {
  background:#A5B4FC;
}
.msg-loading-dots {
  display:flex; gap:5px; padding:12px 18px;
  background:rgba(255,255,255,0.7);
  border:1px solid rgba(0,0,0,0.06);
  border-radius:18px; border-bottom-left-radius:6px;
  backdrop-filter:blur(8px);
}
[data-theme="dark"] .msg-loading-dots {
  background:rgba(40,45,60,0.7);
  border:1px solid rgba(255,255,255,0.08);
}
.msg-loading-dots span {
  width:7px; height:7px; border-radius:50%;
  background:linear-gradient(135deg, #6366f1, #8b5cf6);
  animation:dotPulse 1.4s infinite ease-in-out both;
}
.msg-loading-dots span:nth-child(1) { animation-delay:0s; }
.msg-loading-dots span:nth-child(2) { animation-delay:0.2s; }
.msg-loading-dots span:nth-child(3) { animation-delay:0.4s; }
@keyframes dotPulse {
  0%,80%,100%{transform:scale(0.5);opacity:0.3}
  40%{transform:scale(1.1);opacity:1}
}

/* ===== 输入区（毛玻璃浮动） ===== */
.chat-input-area {
  display:flex; padding:12px 14px; gap:10px;
  background:rgba(255,255,255,0.6);
  border-top:1px solid rgba(0,0,0,0.06);
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
}
[data-theme="dark"] .chat-input-area {
  background:rgba(20,24,35,0.6);
  border-top:1px solid rgba(255,255,255,0.06);
}
.chat-input-area input {
  flex:1; padding:11px 16px;
  border:1px solid rgba(0,0,0,0.1);
  border-radius:22px; font-size:0.9rem; outline:none;
  background:rgba(255,255,255,0.7);
  color:var(--text); font-family:inherit;
  transition:all 0.25s;
  box-shadow:0 1px 4px rgba(0,0,0,0.04);
}
[data-theme="dark"] .chat-input-area input {
  background:rgba(30,35,50,0.7);
  border:1px solid rgba(255,255,255,0.08);
}
.chat-input-area input:focus {
  border-color:#6366f1;
  box-shadow:0 0 0 3px rgba(99,102,241,0.15);
  background:rgba(255,255,255,0.9);
}
.chat-input-area input:disabled {
  background:rgba(243,244,246,0.6); opacity:0.7;
}
[data-theme="dark"] .chat-input-area input:disabled {
  background:rgba(20,24,35,0.4);
}

/* 发送按钮 */
.chat-input-area button {
  width:42px; height:42px; border-radius:50%;
  background:linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color:#fff; border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 0.25s; flex-shrink:0;
  -webkit-tap-highlight-color:transparent;
  box-shadow:0 2px 10px rgba(99,102,241,0.3);
}
.chat-input-area button:hover {
  transform:scale(1.1);
  box-shadow:0 4px 16px rgba(99,102,241,0.4);
}
.chat-input-area button:disabled {
  background:linear-gradient(135deg, #a5b4fc, #c4b5fd);
  box-shadow:none;
  cursor:not-allowed; transform:none;
}

/* 迷你 toast */
.mini-toast { position:fixed; bottom:100px; left:50%; transform:translateX(-50%); padding:10px 20px; background:#333; color:#fff; border-radius:20px; font-size:0.85rem; z-index:9999; animation:toastFade 2.5s ease forwards; white-space:nowrap; }
@media (max-width:640px) { .mini-toast { bottom:80px; font-size:0.8rem; } }
@keyframes toastFade { 0%{opacity:0;transform:translateX(-50%) translateY(10px)} 15%{opacity:1;transform:translateX(-50%) translateY(0)} 85%{opacity:1} 100%{opacity:0} }


/* ==================== 大屏扩宽（≥1024px） ==================== */
@media (min-width:1024px) {
  .container { max-width:1040px; }
  .hero h1 { font-size:3rem; }
  .skills-grid { gap:20px; }
  .skill-card { min-width:160px; padding:24px 28px; }
  .project-card { padding:32px; }
  .contact-list { gap:24px; }
  .chat-widget { bottom: 28px; right: 28px; }
  .chat-toggle { width: 76px; height: 76px; border-radius: 22px; }
  .chat-toggle::before { border-radius: 26px; inset: -8px; }
  .chat-toggle .ai-icon { width: 46px; height: 46px; }
  .chat-unread { min-width: 20px; height: 20px; font-size: 0.72rem; top: -6px; left: -6px; }
  .chat-panel { width: 460px; max-height: 600px; }
}

/* 超宽屏（≥1440px）更宽敞 */
@media (min-width:1440px) {
  .container { max-width:1120px; }
  .chat-widget { bottom: 36px; right: 36px; }
  .chat-toggle { width: 84px; height: 84px; border-radius: 24px; }
  .chat-toggle .ai-icon { width: 52px; height: 52px; }
  .chat-panel { width: 480px; }
}

/* ==================== 触摸优化 ==================== */
@media (hover:none) and (pointer:coarse) {
  .skill-card:hover, .project-card:hover, .contact-item:hover { transform:none; }
  .skill-card:active, .project-card:active, .contact-item:active { transform:scale(0.98); }
  .chat-toggle:hover { transform:none; }
  .chat-toggle:active { transform:scale(0.95); }
  .chat-toggle:hover .avatar-tooltip { opacity:0; }
}
