/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* 全局禁止横向溢出（iOS Safari 需要同时设在 html 和 body） */
html { overflow-x: hidden; }
* { max-width: 100%; }

:root {
  --white:   #ffffff;
  --bg-page: #f5f6fa;     /* 整页极浅灰蓝，与图二一致 */
  --border:  #e8eaed;
  --dark:    #1c1c1e;
  --gray:    #999999;
  --sina:    #f5a623;
  --em:      #e74c3c;
  --cls:     #3d8bcd;
  --dot:     #3d72c8;
  --px:      20px;        /* 统一左右内边距 */
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg-page);
  color: var(--dark);
  font-size: 13px;
  height: 100%;
  overflow: hidden;      /* 页面本身不滚动 */
  max-width: 100vw;      /* 防止任何元素撑出视口宽度 */
  overflow-x: hidden;
}

/* 整体布局：固定顶部 + 可滚动内容区 */
body {
  display: flex;
  flex-direction: column;
}

/* ════════════════════════════════════════════════════════════
   顶栏  —— 纯白极简，与图二一致
════════════════════════════════════════════════════════════ */
.topbar {
  flex-shrink: 0;
  width: 100%;
  height: 40px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--px);
  gap: 6px;
}

.topbar-icon  { font-size: 15px; line-height: 1; flex-shrink: 0; }
.topbar-title { font-size: 14px; font-weight: 700; flex-shrink: 0; }
.topbar-sub   { font-size: 12px; color: var(--gray); flex-shrink: 0; }

/* 右侧（筛选+刷新 — 推到最右） */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-filters { display: flex; gap: 3px; }
.filter-btn {
  padding: 2px 9px;
  border: 1px solid #ddd;
  background: transparent;
  border-radius: 20px;
  font-size: 11px;
  color: var(--gray);
  cursor: pointer;
  line-height: 1.7;
  transition: all .15s;
}
.filter-btn:hover        { border-color: #aaa; color: var(--dark); }
.filter-btn.active       { background: var(--dark); color: #fff; border-color: var(--dark); }
.filter-btn[data-source="新浪"].active   { background: var(--sina); border-color: var(--sina); }
.filter-btn[data-source="东财"].active   { background: var(--em);   border-color: var(--em); }
.filter-btn[data-source="财联社"].active { background: var(--cls);  border-color: var(--cls); }

.refresh-info { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--gray); }
.refresh-dot  { width: 6px; height: 6px; border-radius: 50%; background: #27ae60; }
.refresh-dot.loading { background: #f39c12; animation: blink .9s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ════════════════════════════════════════════════════════════
   时间轴
════════════════════════════════════════════════════════════ */
.timeline-bar {
  flex-shrink: 0;
  width: 100%;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 8px var(--px) 8px;
}

/* ── 第一行：时间轴中央标签 ── */
.tl-clock-row {
  text-align: center;
  margin-bottom: 10px;
  min-height: 24px;
}
/* 实时模式：最新资讯 */
#tl-label-live {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--em);        /* 红色 */
  letter-spacing: .5px;
}
/* 历史模式：当前 xxx */
#tl-label-hist {
  display: none;
  font-size: 12px;
  font-weight: 500;
  color: #444;
  background: #f4f5f9;
  padding: 3px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  letter-spacing: .3px;
}

/* ── 第二行：轨道区 ── */
/* 最外层相对定位容器 */
.timeline-inner { position: relative; width: 100%; overflow: visible; }

/* 两端日期标签 */
.tl-edge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--gray);
  line-height: 1;
  margin-bottom: 4px;
}

/* 轨道区 */
.tl-track-wrap {
  position: relative;
  width: 100%;
  cursor: pointer;       /* 整个轨道区可点击 */
  padding: 6px 0;        /* 扩大点击热区 */
  margin: -6px 0;
  /* 为巴菲特头像留出上方空间 */
  margin-top: 48px;
}

/* 巴菲特彩蛋头像 */
#buffett-avatar {
  position: absolute;
  bottom: calc(100% - 2px);   /* 贴在轨道上方，三角指针对准圆点 */
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 10;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.18));
  transition: left .05s linear;
  line-height: 0;
}

/* 粗黑轨道 */
.timeline-track {
  width: 100%;
  height: 7px;
  background: #d0d3da;   /* 未填充部分：浅灰 */
  position: relative;
  border-radius: 4px;
  overflow: visible;
}

/* 已填充部分（左边到拖动位置） */
.timeline-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--dark);
  border-radius: 4px 0 0 4px;
  pointer-events: none;
  transition: width .05s;
}

/* 拖动手柄（圆点） */
.timeline-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 13px; height: 13px;
  background: var(--dot);
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--dot);
  cursor: grab;
  transition: transform .1s, box-shadow .1s;
  z-index: 2;
}
.timeline-dot:hover,
.timeline-dot.dragging {
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 0 3px var(--dot);
  cursor: grabbing;
}

/* 历史模式 — "回到实时" 按钮（放在顶栏右侧） */
.live-badge {
  display: none;
  font-size: 11px;
  font-weight: 600;
  background: var(--em);
  color: #fff;
  padding: 3px 10px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.7;
  transition: background .15s;
}
.live-badge:hover   { background: #c0392b; }
.live-badge.visible { display: inline-block; }

/* 刻度区（轨道下方） */
.timeline-ticks {
  position: relative;
  height: 18px;
  margin-top: 3px;
  overflow: hidden;   /* 两端刻度不超出容器 */
}
.tl-tick {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: var(--gray);
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   新闻列表  —— 全宽，padding 与顶栏对齐
════════════════════════════════════════════════════════════ */
.news-container {
  flex: 1;          /* 占满剩余高度 */
  overflow-y: auto; /* 只有这里滚动 */
  width: 100%;
  background: var(--white);
  padding-bottom: 80px;
}

.news-list { display: flex; flex-direction: column; }

/* 每行 */
.news-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px var(--px);     /* 左右 padding 与顶栏完全一致 */
  border-bottom: 1px solid var(--border);
  background: var(--white);
  transition: background .1s;
}
.news-item:hover   { background: #fafbfc; }
.news-item.new-in  { animation: fadein .25s ease; }
@keyframes fadein  { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:none} }

/* 时间 */
.news-time {
  width: 34px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--gray);
  line-height: 1.8;
}

/* 来源 badge */
.news-source {
  flex-shrink: 0;
  width: 36px;        /* 固定宽度，以"财联社"为基准 */
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 0;
  border-radius: 2px;
  color: #fff;
  line-height: 1.8;
  white-space: nowrap;
}
.s-sina { background: var(--sina); }
.s-em   { background: var(--em);   }
.s-cls  { background: var(--cls);  }

/* 正文 */
.news-content {
  flex: 1;
  min-width: 0;              /* flex 子元素必须设，否则不会收缩 */
  font-size: 13px;
  line-height: 1.7;
  color: var(--dark);
  overflow-wrap: break-word; /* 长 URL / 英文单词强制折行 */
  word-break: break-word;
}
.news-content a { color: inherit; text-decoration: none; }
.news-content a:hover { color: #2980b9; }

/* 日期分割 */
.date-sep {
  padding: 5px var(--px);
  font-size: 11px;
  color: var(--gray);
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
}

/* ════════════════════════════════════════════════════════════
   加载 / 空态
════════════════════════════════════════════════════════════ */
.loading-wrap {
  display: flex; flex-direction: column;
  align-items: center; padding: 60px 20px;
  color: var(--gray); gap: 12px;
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--dark);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }
.empty-msg { text-align: center; padding: 40px; color: var(--gray); }

/* 悬浮刷新 */
.fab {
  position: fixed; bottom: 22px; right: 22px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--dark); color: #fff; font-size: 17px;
  border: none; cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.2);
  transition: transform .2s, background .2s; z-index: 200;
}
.fab:hover    { background: #333; transform: scale(1.08) rotate(20deg); }
.fab.spinning { animation: spin .6s linear infinite; }

/* ════════════════════════════════════════════════════════════
   移动端适配  ≤ 640px
════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root { --px: 12px; }

  /* 顶栏：两行布局 */
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 6px var(--px);
    row-gap: 6px;
  }
  /* 第一行：标题 + 更新信息 */
  .topbar-title { font-size: 13px; }
  .topbar-sub   { display: none; }   /* 条数隐藏，节省空间 */
  .topbar-right {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  /* 筛选按钮稍小 */
  .filter-btn { font-size: 11px; padding: 2px 8px; }

  /* 时间轴标签缩小 */
  .tl-edge-labels { font-size: 10px; }
  .tl-tick        { font-size: 10px; }
  .tl-clock-row   { margin-bottom: 6px; }
  .timeline-bar   { padding: 6px var(--px); }

  /* 巴菲特头像移动端缩小 */
  #buffett-avatar svg { width: 32px; height: 39px; }
  .tl-track-wrap  { margin-top: 36px; }

  /* 新闻条目 */
  .news-item    { padding: 8px var(--px); gap: 7px; }
  .news-time    { font-size: 11px; width: 30px; }
  .news-content { font-size: 13px; line-height: 1.65; }

  /* FAB 靠近边缘 */
  .fab { width: 34px; height: 34px; font-size: 15px;
         bottom: 14px; right: 14px; }
}
