/* ==================== 1. 设计令牌 (Design Tokens) ==================== */
:root {
  /* --- 柔和暗色系 --- */
  --bg-dark: #08080a;        /* 接近黑色的深暖灰 */
  --bg-card: rgba(30, 30, 35, 0.4); /* 卡片底色 */
  
  /* --- 弥散光强调色 (低饱和，高级) --- */
  --accent-glow: #6366f1;    /* 靛蓝 */
  --accent-soft: #a5b4fc;    /* 柔和紫 */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  
  /* --- 文本色 --- */
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-muted: #64748b;
  
  /* --- 材质参数 --- */
  --glass-blur: 40px;        /* 强模糊，像磨砂玻璃 */
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-highlight: rgba(255, 255, 255, 0.1);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  
  /* --- 动画 --- */
  --ease-soft: cubic-bezier(0.25, 0.8, 0.25, 1);
}



/* ==================== 字体：HarmonyOS Sans SC ==================== */
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Thin.ttf") format("truetype"); font-weight: 100; font-style: normal; font-display: swap; }
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Light.ttf") format("truetype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "HarmonyOS Sans SC"; src: url("HarmonyOS_Sans_SC_Black.ttf") format("truetype"); font-weight: 900; font-style: normal; font-display: swap; }

/* ==================== 2. 全局重置 ==================== */
* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body { font-family: "HarmonyOS Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; 
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  font-weight: 400;
}

/* ==================== 3. 弥散氛围背景 (核心高级感来源) ==================== */
.ambient-background {
  position: fixed; inset: 0; z-index: -1;
  overflow: hidden;
  background: var(--bg-dark);
}

.light-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px); /* 极度柔化 */
  opacity: 0.4;
  animation: float-blob 15s infinite alternate ease-in-out;
}

.blob-1 {
  top: -10%; left: -10%; width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent 70%);
}

.blob-2 {
  bottom: -10%; right: -10%; width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.12), transparent 70%);
  animation-delay: -5s;
}

.blob-3 {
  top: 40%; left: 40%; width: 30vw; height: 30vw;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.08), transparent 70%);
  animation-delay: -10s;
}

@keyframes float-blob {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(20px, -20px) scale(1.1); }
}

/* ==================== 4. 玻璃拟态卡片 (Glass Surface) ==================== */
.glass-surface {
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3); /* 柔和阴影 */
  transition: transform 0.3s var(--ease-soft), box-shadow 0.3s var(--ease-soft);
}

/* 交互悬浮态 */
.glass-surface:hover {
  border-color: var(--glass-highlight);
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

/* ==================== 5. 导航栏 ==================== */
.navbar {
  background-color: #08080a;
  position: fixed; top: 0; left: 0; width: 100%;
  height: 80px;
  display: flex; justify-content: center;
  z-index: 100;
  pointer-events: none; /* 让两侧不可点击区域穿透 */
}

.nav-content {
  width: 100%; max-width: 1000px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: auto;
}

.app-logo {
  display: flex; align-items: center; gap: 12px;
}

.logo-circle {
  width: 40px; height: 40px;
  background: var(--accent-gradient);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.app-name {
  font-weight: 600; font-size: 18px; letter-spacing: -0.5px;
  color: var(--text-main);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
  font-size: 18px;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.05);
}

/* ==================== 6. 容器与布局 ==================== */
.main-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 100px 24px 60px;
  min-height: 100vh;
}

.page { display: none; animation: fadeInSoft 0.6s var(--ease-soft); }
.page.active { display: block; }

@keyframes fadeInSoft {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== 7. 录音页 (极简中心) ==================== */
.center-focus {
  display: flex; flex-direction: column; align-items: center; gap: 40px;
  margin-top: 4vh;
}

.header-group { text-align: center; }
.main-title {
  font-size: 42px; font-weight: 700;
  margin-bottom: 12px;
  background: linear-gradient(to bottom right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
}
.main-subtitle { color: var(--text-muted); font-size: 16px; font-weight: 300; }

.visualizer-card {
  width: 100%; max-width: 400px; height: 260px;
  position: relative;
  overflow: hidden;
}
.webgl-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.pulse-ring {
  width: 60px; height: 60px; border-radius: 50%;
  border: 2px solid var(--accent-soft);
  opacity: 0.5;
  animation: pulse-ring 3s infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

.record-btn-soft {
  width: 200px; height: 64px;
  background: var(--text-main);
  border: none; border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s var(--ease-soft);
  box-shadow: 0 10px 30px rgba(255, 255, 255, 0.15);
  position: relative; overflow: hidden;
}

.record-btn-soft .btn-content {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #000; font-weight: 600; font-size: 16px; height: 100%;
}

.record-btn-soft:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(255, 255, 255, 0.25);
}
.record-btn-soft:active { transform: translateY(-1px); }

/* 录音中状态 */
.record-btn-soft.recording {
  background: #ef4444; /* 柔和红 */
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.3);
}
.record-btn-soft.recording .btn-content { color: white; }
.record-btn-soft.recording i { animation: fade 1s infinite; }

.status-indicator {
  color: var(--text-muted); font-size: 13px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 16px; border-radius: 20px;
}

/* ==================== 8. 结果页 (Dashboard) ==================== */
.nav-header {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 24px;
}
.back-btn-simple {
  background: transparent; border: none; color: var(--text-main);
  font-size: 20px; cursor: pointer; padding: 8px; opacity: 0.7;
  transition: opacity 0.2s;
}
.back-btn-simple:hover { opacity: 1; }
.nav-header h2 { font-size: 24px; font-weight: 600; }

/* 情绪高亮卡片 */
.emotion-highlight-card {
  padding: 32px;
  display: flex; justify-content: space-between; align-items: flex-end;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(30, 30, 35, 0.4) 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  margin-bottom: 20px;
}

.emotion-visual-area { display: flex; align-items: center; gap: 24px; }
.emotion-icon-large { font-size: 64px; filter: drop-shadow(0 10px 20px rgba(0,0,0,0.2)); }
.emotion-text-group { display: flex; flex-direction: column; gap: 4px; }
.emotion-text-group .label { font-size: 12px; color: var(--accent-soft); letter-spacing: 1px; text-transform: uppercase; }
.emotion-title { font-size: 32px; font-weight: 700; color: white; }

.confidence-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.08); padding: 4px 12px; border-radius: 12px;
  font-size: 18px; color: var(--text-sub); margin-top: 8px;
}
.confidence-pill .dot { width: 6px; height: 6px; background: var(--accent-soft); border-radius: 50%; }

.meta-item {
  text-align: right;
  display: flex; flex-direction: column; gap: 8px;
}
.meta-label { font-size: 12px; color: var(--text-muted); }
.meta-value { font-size: 14px; color: var(--text-sub);}

/* 文本与图表 */
.text-card { padding: 24px; min-height: 140px; margin-bottom: 20px; }
.card-title { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.speech-content { font-size: 16px; color: var(--text-sub); line-height: 1.8; }

.charts-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 30px; }
.chart-card { padding: 20px; }
.chart-box-sq { height: 240px; }
.chart-box-wide { height: 200px; }

/* 底部操作 */
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.soft-btn {
  height: 56px; border: none; border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05); color: var(--text-main);
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: 0.3s;
}
.soft-btn:hover { background: rgba(255,255,255,0.1); }
.soft-btn.primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}
.soft-btn.primary:hover { box-shadow: 0 12px 30px rgba(99, 102, 241, 0.4); transform: translateY(-2px); }

/* ==================== 9. 日志页 ==================== */
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-only { width: 36px; height: 36px; border-radius: 8px; border: none; background: rgba(255,255,255,0.05); color: var(--text-sub); cursor: pointer; transition: 0.2s; }
.icon-only:hover { background: rgba(255,255,255,0.1); color: white; }
.icon-only.danger:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }

.logs-container { padding: 16px; min-height: 400px; }
.log-item {
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; gap: 4px;
}
.log-item:last-child { border-bottom: none; }
.log-item:hover { background: rgba(255,255,255,0.02); padding-left: 24px; }
.log-header { display: flex; justify-content: space-between; }
.log-emotion-name { color: var(--accent-soft); font-weight: 500; }
.log-time { font-size: 12px; color: var(--text-muted); }
.log-text { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-placeholder { text-align: center; padding: 60px 0; color: var(--text-muted); }

/* ==================== 10. 全局遮罩 (Breathing Loader) ==================== */
.loading-screen {
  position: fixed; inset: 0; background: rgba(8, 8, 10, 0.8);
  backdrop-filter: blur(20px); z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.hidden { display: none; }

.breathing-orb {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent-gradient);
  animation: breathe 2s ease-in-out infinite;
  box-shadow: 0 0 40px rgba(99, 102, 241, 0.4);
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(0.6); opacity: 0.4; }
}
.loading-label { margin-top: 24px; font-size: 14px; letter-spacing: 2px; color: var(--text-sub); text-transform: uppercase; }

/* ==================== 11. 响应式 ==================== */
@media (min-width: 768px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
  .emotion-highlight-card { padding: 40px; }
}

/* Responsive: Emotion meta (小屏幕将“维度定位”等信息下移成独立区域) */
@media (max-width: 520px) {
  .emotion-highlight-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .emotion-meta {
    width: 100%;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--glass-border);
  }
  .meta-item {
    text-align: left;
    align-items: flex-start;
  }
  .meta-value {
    word-break: break-word;
  }

/* ==================== 弹窗（历史记录详情） ==================== */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 9999;
}
.modal-overlay.open{ display:flex; }
.modal{
  width: min(720px, 100%);
  border-radius: 18px;
  padding: 16px;
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-title{
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--text-main);
  font-weight: 600;
}
.modal-body{ display:flex; flex-direction:column; gap: 14px; }

.log-modal-card{ margin-bottom: 0; }
.log-modal-text .speech-content{ font-size: 15px; }

#logs-list:has(.log-item) #logs-empty{ display:none; }



/* ==================== 情绪象限图 (重新设计) ==================== */

/* 主容器 - 玻璃质感 */
.quad-demo {
  position: relative; /* 关键：为绝对定位的子元素提供定位上下文 */
  border-radius: 24px;
  padding: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
  background: 
    linear-gradient(180deg, rgba(12,13,18,0.6), rgba(10,11,16,0.9));
  box-shadow: 
    0 20px 60px rgba(0,0,0,0.4) inset,
    0 10px 30px rgba(0,0,0,0.3);
}

/* 点阵背景层 - 模拟坐标纸 */
.quad-demo::before {
  content: '';
  position: absolute;
  inset: 24px;
  background-image:
    repeating-linear-gradient(
      0deg, 
      rgba(255,255,255,0.08) 0px, 
      rgba(255,255,255,0.08) 1px, 
      transparent 1px, 
      transparent 20px
    ),
    repeating-linear-gradient(
      90deg, 
      rgba(255,255,255,0.08) 0px, 
      rgba(255,255,255,0.08) 1px, 
      transparent 1px, 
      transparent 20px
    );
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}

/* 网格容器 - 在点阵之上 */
.quad-grid-wrap {
  position: relative;
  width: min(540px, 90%);
  aspect-ratio: 1 / 1;
  margin: 64px auto 56px;
  z-index: 2;
}

/* 四个象限格子 */
.quad-cells {
  position: absolute;
  inset: 16px; /* 留足边距给图标 */
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
}

.quad-cell {
  border-radius: 20px;
  background: 
    radial-gradient(120% 120% at 20% 20%, rgba(255,255,255,0.04), transparent 60%),
    rgba(0,0,0,0.3);
  box-shadow: 
    0 10px 30px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.06) inset;
  animation: cellBreath 7s ease-in-out infinite;
}

@keyframes cellBreath {
  0%, 100% { 
    filter: brightness(0.95); 
    transform: translateZ(0); 
  }
  50% { 
    filter: brightness(1.05); 
    transform: translateY(-1px); 
  }
}

/* 四边图标 - 固定在格子容器边缘中心点 */
.quad-edge-icon {
  position: absolute;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 26px;
  z-index: 3;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

/* 图标对齐到 .quad-grid-wrap 的边缘 */
.quad-edge-icon.top { 
  left: 50%; 
  top: calc(24px + 64px); /* padding(24px) + margin-top(64px) = 88px */
  transform: translate(-50%, -50%); 
  color: rgba(250,204,21,0.95); 
}

.quad-edge-icon.bottom { 
  left: 50%; 
  bottom: calc(24px + 56px); /* padding(24px) + margin-bottom(56px) = 80px */
  transform: translate(-50%, 50%); 
  color: rgba(248,113,113,0.95); 
}

.quad-edge-icon.left { 
  left: 8%; /* 增加百分比 = 往右偏移 */
  top: calc(50% + 4px); 
  transform: translate(-50%, -50%); 
  color: rgba(125,211,252,0.95); 
}

.quad-edge-icon.right { 
  right: 8%; /* 增加百分比 = 往左偏移 */
  top: calc(50% + 4px); 
  transform: translate(50%, -50%); 
  color: rgba(253,224,71,0.95); 
}

/* 坐标变量 */
.quad-demo {
  --px: 50;
  --py: 50;
}

/* 标记点容器 - 根据坐标定位 */
.quad-marker {
  position: absolute;
  left: calc(32px + (100% - 64px) * var(--px) / 100);
  top: calc(32px + (100% - 64px) * var(--py) / 100);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 4;
  transition: left 500ms cubic-bezier(0.34, 1.56, 0.64, 1), 
              top 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 点 */
.quad-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  box-shadow: 
    0 0 0 6px rgba(255,255,255,0.1),
    0 4px 12px rgba(0,0,0,0.4);
  transition: all 300ms ease;
}

/* 标签 - 智能浮动 */
.quad-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  white-space: nowrap;
}

.quad-badge i {
  font-size: 16px;
  opacity: 0.95;
}

/* 根据象限改变颜色 */
.quad-demo[data-q="q1"] .quad-dot { background: rgba(248,113,113,0.95); }
.quad-demo[data-q="q1"] .quad-badge { color: rgba(248,113,113,1); border-color: rgba(248,113,113,0.3); }

.quad-demo[data-q="q2"] .quad-dot { background: rgba(192,132,252,0.95); }
.quad-demo[data-q="q2"] .quad-badge { color: rgba(192,132,252,1); border-color: rgba(192,132,252,0.3); }

.quad-demo[data-q="q3"] .quad-dot { background: rgba(96,165,250,0.95); }
.quad-demo[data-q="q3"] .quad-badge { color: rgba(96,165,250,1); border-color: rgba(96,165,250,0.3); }

.quad-demo[data-q="q4"] .quad-dot { background: rgba(251,191,36,0.95); }
.quad-demo[data-q="q4"] .quad-badge { color: rgba(251,191,36,1); border-color: rgba(251,191,36,0.3); }

/* 点位脉冲动画 */
.quad-pulse .quad-dot {
  animation: markerPulse 600ms ease-out 1;
}

@keyframes markerPulse {
  0% { 
    transform: scale(0.8); 
    box-shadow: 0 0 0 3px rgba(255,255,255,0.05); 
  }
  60% { 
    transform: scale(1.2); 
    box-shadow: 0 0 0 12px rgba(255,255,255,0.15); 
  }
  100% { 
    transform: scale(1); 
    box-shadow: 0 0 0 6px rgba(255,255,255,0.1); 
  }
}

/* 响应式调整 */
@media (max-width: 600px) {
  .quad-demo {
    padding: 20px;
  }
  
  .quad-grid-wrap {
    width: 94%;
    margin: 54px auto 48px;
  }
  
  .quad-cells {
    inset: 12px;
    gap: 12px;
  }
  
  .quad-edge-icon {
    font-size: 22px;
    width: 28px;
    height: 28px;
  }
  
  /* 更新图标位置以匹配新的margin和padding */
  .quad-edge-icon.top {
    top: calc(20px + 54px); /* padding(20px) + margin-top(54px) */
  }
  
  .quad-edge-icon.bottom {
    bottom: calc(20px + 48px); /* padding(20px) + margin-bottom(48px) */
  }
  
  .quad-edge-icon.left {
    left: 6%; /* 往内偏移 */
  }
  
  .quad-edge-icon.right {
    right: 6%; /* 往内偏移 */
  }
  
  .quad-marker {
    left: calc(28px + (100% - 56px) * var(--px) / 100);
    top: calc(28px + (100% - 56px) * var(--py) / 100);
  }
}

/* Modal content spacing */
.modal-body .emotion-highlight-card { 
  margin-bottom: 14px; 
}

/* Chart container sizing */
.chart-box-sq { 
  height: auto; 
  min-height: 560px; 
}