/* ==========================================================================
   微迹 Weetrack — 时间轴
   --------------------------------------------------------------------------
   布局（用户要的「节点在底部，上方一行行一框框的信息流」）：

     顶部   汇总 + 档位 + 筛模块
     中间   信息流（左边缘一条竖线 = 时间在流动）
     底部   横向日期轴，一天一个节点，可左右滑动

   底部那条轴要「粘」在视口底部 —— 否则往下读信息流时它就滚走了，
   而它正是"我在时间轴上的哪个位置"的指示器，必须一直看得见。
   ========================================================================== */

.tl-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* 【给底部那条轴留位置】
     轴是 position: sticky; bottom: 0 的，会盖住内容。
     所以内容区底部要留出和它一样高的空白。 */
  padding-bottom: 0;
}

/* ============================ 顶部 ============================ */

.tl-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 标题 + 工具区那一行（和待办/灵感/记账的 .page-head 同一个形状：
   左边标题、右边工具；窄屏自己折行） */
.tl-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tl-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.tl-title > span:first-child {
  font-size: 15px;
  opacity: .6;
}
.tl-title h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .3px;
}
.tl-sub {
  font-size: 12.5px;
  color: var(--text-3);
}

.tl-tools {
  display: flex;
  align-items: center;
  /* 工具区自己靠右（它在 .tl-top 里已经是右侧那一组了，
     所以这里不再用 space-between 把它和标题拉开） */
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* 档位切换（7 / 30 / 90 天）
   ------------------------------------------------------------------
   【样式 2026-09-27 搬到"公共控件"去了】
   这里原来是自己写的一套（.tl-seg 边框胶囊 + .tl-seg-btn），
   注释里写着"和日程那套分段控件一致"—— 其实高度、圆角、字号都差一点，
   而**位置**也不一样（那套在页头右侧）。
   现在用 util.js 的 segment() 渲染成 `.segment`（见 base.css），
   位置就在页头右侧、和翻页按键并排。
   .tl-seg / .tl-seg-btn / .on 仍留在 DOM 上 ——
   check:timeline-ui 按 .tl-seg-btn 找档位按钮，所以不再给它们画东西。 */

.tl-nav { display: flex; gap: 4px; align-items: center; }

.tl-nav button {
  font: inherit;
  font-size: 11.5px;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.tl-nav button:hover { background: var(--surface-2); color: var(--text); }
.tl-today-btn { border-color: var(--line) !important; }

/* ============================ 汇总条 ============================ */

.tl-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.tl-sum-range {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tl-sum-days {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-3);
}

.tl-sum-bits {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.tl-sum-bit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-2);
}
.tl-sum-bit i {
  font-style: normal;
  opacity: .7;
}

/* ============================ 模块筛选 ============================ */

.tl-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tl-chip {
  font: inherit;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tl-chip:hover { border-color: var(--text-3); color: var(--text); }
.tl-chip i { font-style: normal; font-size: 11px; opacity: .7; }
.tl-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}
.tl-chip.on i { opacity: .95; }

/* ============================ 信息流 ============================ */

.tl-flow {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 200px;
}

.tl-day {
  display: flex;
  gap: 12px;
  padding-bottom: 14px;
}

/* 左边那条"时间在流动"的竖线 */
.tl-rail {
  flex: 0 0 14px;
  position: relative;
  display: flex;
  justify-content: center;
}
.tl-rail::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: -14px;
  width: 1px;
  background: var(--line);
}
.tl-day:last-child .tl-rail::before { bottom: 50%; }

.tl-dot {
  position: relative;
  z-index: 1;
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--line-strong);
  border: 2px solid var(--surface);
  box-sizing: content-box;
}
.tl-day.today .tl-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tl-day-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tl-day-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.tl-day-date {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tl-day-week {
  font-size: 11.5px;
  color: var(--text-3);
}

.tl-day-now {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

.tl-day-n {
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
}

/* 点底部节点跳过来时，闪一下让人知道"就是这一天" */
.tl-day.flash .tl-day-main {
  animation: tl-flash 1.2s ease;
}
@keyframes tl-flash {
  0% { background: var(--accent-soft); border-radius: 10px; }
  100% { background: transparent; }
}

/* ============================ 一条记录 ============================ */

.tl-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  /* 左边一条分类色带，一眼看出来自哪个模块 */
  border-left-width: 3px;
  transition: border-color .15s, transform .1s;
}

.tl-card.clickable { cursor: pointer; }
.tl-card.clickable:hover {
  border-color: var(--line-strong);
  transform: translateX(2px);
}

.tl-card-ico {
  flex: 0 0 auto;
  font-size: 13px;
  width: 20px;
  text-align: center;
  opacity: .8;
}

.tl-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

.tl-card-title {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-card-detail {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tl-card-time {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.tl-card-go {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 14px;
  opacity: .4;
}
.tl-card.clickable:hover .tl-card-go { opacity: .9; }

/* 完成的待办压暗并划线 */
.tl-card.done .tl-card-title {
  text-decoration: line-through;
  color: var(--text-3);
}

/* 各模块的色带 */
.tl-card.m-todo { border-left-color: #4a8f6a; }
.tl-card.m-diary { border-left-color: var(--green); }
.tl-card.m-mood { border-left-color: #c8553d; }
.tl-card.m-slice { border-left-color: #4a7fa8; }
.tl-card.m-trip { border-left-color: #a86fa8; }
.tl-card.m-idea { border-left-color: #d59a2e; }
.tl-card.m-ledger { border-left-color: var(--violet); }

/* 心情按分数换颜色：低分偏冷、高分偏暖 */
.tl-card.m-mood.lv-1, .tl-card.m-mood.lv-2 { border-left-color: #6b8cae; }
.tl-card.m-mood.lv-4, .tl-card.m-mood.lv-5 { border-left-color: #c98b3d; }

/* ============================ 空状态 ============================ */

.tl-empty {
  padding: 40px 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.8;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

/* ============================ 底部日期轴 ============================ */

/* ==========================================================================
   紧贴底部（2026-09-26 补）
   --------------------------------------------------------------------------
   用户要求：「底部日期轴改为紧贴底部」。

   轴自己是 `position: sticky; bottom: 0`，按说不该有缝，但实测差 40px：
   轴底边在 860px、视口 900px。来源是 **`#view` 自己的下内边距** ——
   `index.html` 里是 `<main class="main" id="view">`，也就是说 `.main` 和
   `#view` 是**同一个元素**，而 `.main` 有 `padding: … 40px`。
   sticky 受容器盒约束，所以轴到不了那 40px 以下。

   那 40px 对别的页面是有用的（内容读到底要留点呼吸），所以**只在这一页去掉**。
   认 `tl-fill` 这个 class，而不是复用 `view-fill`：
   邮箱页和 Agent 页也用 view-fill，它们不需要改内边距。
   ========================================================================== */
#view.tl-fill {
  padding-bottom: 0;
}
/* 贴底的东西不该带圆角和下边框 —— 那会显得还"浮着" */
#view.tl-fill > .view-host > .tl-body > .tl-axis {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 0;
  margin-bottom: 0;
}

/* ==========================================================================
   底部日期轴 · 可框选的时间区域
   --------------------------------------------------------------------------
   用户要求：「改为可选择时间区域，类似于剪辑软件的左右滑动点」。

   节点条上面盖一条半透明选择带，两端各一个可拖的把手，
   拖动时**按天吸附**（松手一定落在某一天的边界上）。
   ========================================================================== */

/* 框选信息（只在框了的时候出现） */
.tl-axis-sel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 6px;
}
.tl-axis-sel[hidden] { display: none; }
.tl-axis-sel-text {
  font-size: 11.5px;
  color: var(--brand, #48ab93);
  font-variant-numeric: tabular-nums;
}
.tl-axis-clear {
  font: inherit;
  font-size: 11px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  cursor: pointer;
}
.tl-axis-clear:hover { color: var(--text-1); border-color: var(--line-strong); }

/* 选择带 */
.tl-sel {
  position: absolute;
  top: 0;
  bottom: 0;
  /* 压在节点上面，两端的把手要能点到 */
  z-index: 3;
  background: rgba(107, 122, 90, .16);
  border-left: 2px solid var(--brand, #48ab93);
  border-right: 2px solid var(--brand, #48ab93);
  border-radius: 6px;
  /* 【关键】带子本身不接收指针事件，否则会把下面节点的点击吃掉；
     只有两端那对小把手收事件。 */
  pointer-events: none;
}
.tl-sel[hidden] { display: none; }
/* 拖动中加深一点，让人知道"正在拉" */
.tl-sel.dragging { background: rgba(107, 122, 90, .26); }

/* 两端的小把手 —— 形状照着剪辑软件那种"夹子" */
.tl-h {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  pointer-events: auto;
  cursor: ew-resize;
  /* 【只在把手上禁用滚动手势】
     手柄很小，在它上面禁用不影响别处；整条轴禁用的话手机就滚不动了。
     这一条 + pointer 事件，鼠标和手指都能拖。 */
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tl-h::after {
  content: '';
  width: 4px;
  height: 60%;
  min-height: 18px;
  border-radius: 3px;
  background: var(--brand, #48ab93);
  box-shadow: 0 0 0 2px var(--surface);
}
.tl-h:hover::after,
.tl-sel.dragging .tl-h::after { background: var(--brand-strong, #55643f); }
.tl-h.left { left: -8px; }
.tl-h.right { right: -8px; }

/* 轨道要能当定位参照：选择带是按节点的 offsetLeft 摆的，
   而 offsetLeft 是相对**最近的定位祖先**算的。 */
.tl-axis-track { position: relative; }

/* 【撑满主区高度 —— 把日期轴压到视口最底部】
 *
 * 用户的原话：「时间轴的时间选择应该在底部才对，
 * 而不是随着内容多少而变化」。
 *
 * 之前只写了 `position: sticky; bottom: 0`，那是不够的：
 * sticky 只在元素"本来会滚出视口"时才把它钉住。
 * 内容比视口短的时候它压根不会触发 —— 轴就停在内容末尾、
 * 悬在半空，下面留一大片空白（实测视口 2100px 时空了 466px）。
 *
 * 这里用一条 flex 链把高度传下去：
 *   .main（高度确定，flex 子项 + 100vh 外壳）
 *     └ #view.view-fill（min-height:100% → 撑满主区内容盒）
 *         └ .view-host（flex:1 → 长满）
 *             └ .tl-body（flex:1 → 长满）
 *                 └ .tl-axis（margin-top:auto → 被推到底部）
 *
 * 【为什么用 min-height 而不是 height】
 * 内容多的时候（比如一次看两个月）它还得能正常往下长，
 * 不能被固定高度裁掉。min-height 只保证"至少占满一屏"。
 *
 * 【为什么挂在 #view 上】
 * #view 是 .main 的直接子元素，百分比能解析到 .main 的确定高度。
 * 中间夹着的 .view-host / .tl-body 都是自动高度，
 * 所以必须让 #view 也参与这条链，否则百分比会断掉。
 */
#view.view-fill {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
#view.view-fill > .view-host {
  flex: 1 1 auto;
}
#view.view-fill > .view-host > .tl-body {
  flex: 1 1 auto;
}

.tl-axis {
  /* 【粘在视口底部】
     往下读信息流时它不能滚走 —— 它是指示"当前位置"的。
     加 z-index 免得被卡片盖住。

     margin-top: auto 是配合上面的 flex 链用的：
     在 .tl-body 这个 flex 列里，它会把轴推到最下面。
     内容短的时候，多出来的空间全在轴的上方 —— 这正是要的效果。 */
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  /* 上边加一点阴影，和信息流分开 */
  box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, .22);
  margin-top: auto;
}

.tl-axis-track {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  /* 横向滚动条细一点，别抢视线 */
  scrollbar-width: thin;
  padding-bottom: 2px;
}
.tl-axis-track::-webkit-scrollbar { height: 6px; }
.tl-axis-track::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

.tl-axis-empty {
  padding: 12px;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
  width: 100%;
}

/* 一个日期节点 */
.tl-node {
  font: inherit;
  flex: 0 0 auto;
  /* 宽度固定，这样 N 天的轴长度稳定、好定位 */
  width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 2px 4px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.tl-node:hover { background: var(--surface-2); }

/* 周末的数字淡一点，一眼看出周的节奏 */
.tl-node.weekend .tl-node-d { opacity: .65; }

/* 有记录的那天颜色重一些 */
.tl-node.has { color: var(--text-2); }

.tl-node.today {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.tl-node-w { font-size: 9.5px; }
.tl-node-d {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

/* 节点下方的小横条：有记录就是实心，没记录是空心的 */
.tl-node-bar {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  transition: opacity .15s;
}
.tl-node.today .tl-node-bar { background: var(--accent); }

/* 条数的角标 */
.tl-node-n {
  font-size: 9px;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ============================ 窄屏 ============================ */

@media (max-width: 700px) {
  .tl-tools { flex-direction: column; align-items: stretch; }
  .tl-seg { overflow-x: auto; }
  .tl-node { width: 34px; }
  .tl-sum-bits { gap: 4px 10px; }
  .tl-card-time { display: none; }
  .tl-day-n { display: none; }
}
