/* ==========================================================================
   小禾AI实践 · AI 简报 — 设计系统
   --------------------------------------------------------------------------
   设计说明（frontend-design 方法：先定 token，再写组件，最后自检）

   主题：把「一天一期 × 三条赛道」这个结构本身做成视觉装置。
     · 报头用中文衬线排日期（宋体骨相 = 报纸的权威感，与满屏无衬线区分）；
     · 日期下一条三色细带（蓝 / 金 / 青）＝ 三条赛道的图例，是信息，不是装饰；
     · 赛道段落用左侧色脊区分，不用卡片盒子；
     · 「落地行动」是主理人工作笔记 → 窄边栏 + 极淡金底，与机器整理的部分区分开。

   刻意的取舍（避开模板化默认）：
     · 不做等半径卡片墙、不用软灰投影、不用渐变洗底；
     · 不用全大写小标签、不给标题加无意义编号；
     · 圆角只给可交互元素（按钮 / 焦点态）；
     · 动效只做一次「换期入场」，不做逐段上浮。
   ========================================================================== */

/* ---- Layer 1：原始 token --------------------------------------------------- */
:root {
  /* 深色（默认画布）：墨蓝，不是纯黑 */
  --l-navy-950: #0a141f;
  --l-navy-900: #0d1a27;
  --l-navy-850: #101f2e;
  --l-navy-800: #142638;
  --l-line: #1c3049;
  --l-line-soft: #17283d;
  --l-text: #e9eff7;
  --l-text-2: #b3c5da;
  --l-text-3: #8b9cb3;

  --l-blue: #4c86ff;
  --l-blue-deep: #1b4bb8;
  --l-gold: #e3b15e;
  --l-teal: #3fc0a6;

  /* 浅色：纸面 */
  --l-paper: #f6f7f9;
  --l-paper-2: #ffffff;
  --l-paper-line: #dde2e9;
  --l-paper-text: #16202b;
  --l-paper-text-2: #4c5a6a;
  --l-paper-blue: #1d5bd8;
  --l-paper-gold: #855816;       /* 原 #9c6b1f 对纸色 4.32:1，不过 AA（2026-09-21 实测修正） */
  --l-paper-teal: #0f8c76;

  /* 字体：标题衬线 / 正文无衬线（只有一个刻意的对比，不做多字体混排） */
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "Source Han Serif CN", STSong, SimSun, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;

  /* 字号阶梯 */
  --fs-masthead: 36px;
  --fs-track: 25px;
  --fs-lead: 19px;
  --fs-body: 16.5px;
  --fs-small: 14.5px;
  --fs-micro: 12.5px;

  --lh-body: 1.78;
  --lh-tight: 1.25;

  --radius-ctl: 8px;
  --rail-w: 216px;
  --shell-max: 1100px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Layer 2：语义 token（主题只在这一层切换） ------------------------------ */
:root,
[data-theme="dark"] {
  --canvas: var(--l-navy-950);
  --surface: var(--l-navy-850);
  --surface-2: var(--l-navy-800);
  --hairline: var(--l-line);
  --hairline-soft: var(--l-line-soft);
  --ink: var(--l-text);
  --ink-2: var(--l-text-2);
  --ink-3: var(--l-text-3);
  --accent: var(--l-blue);
  --accent-ink: var(--l-blue);
  --gold: var(--l-gold);
  --teal: var(--l-teal);
  --note-bg: rgba(227, 177, 94, 0.06);
  --hover-bg: rgba(76, 134, 255, 0.08);
  --shadow-top: 0 1px 0 rgba(255, 255, 255, 0.03);
}

[data-theme="light"] {
  --canvas: var(--l-paper);
  --surface: var(--l-paper-2);
  --surface-2: var(--l-paper-2);
  --hairline: var(--l-paper-line);
  --hairline-soft: #e8ebf0;
  --ink: var(--l-paper-text);
  --ink-2: var(--l-paper-text-2);
  --ink-3: #5d6b80;              /* 原 #66748a 对纸色仅 4.42:1，不过 AA（2026-09-21 实测修正） */
  --accent: var(--l-paper-blue);
  --accent-ink: var(--l-paper-blue);
  --gold: var(--l-paper-gold);
  --teal: var(--l-paper-teal);
  --note-bg: rgba(156, 107, 31, 0.055);
  --hover-bg: rgba(29, 91, 216, 0.06);
  --shadow-top: 0 1px 0 rgba(0, 0, 0, 0.02);
}

/* ---- Layer 3：基础 --------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration-color: color-mix(in srgb, var(--accent-ink) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl);
  font-size: var(--fs-small);
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---- 顶栏：左字标 / 右主理人 ---------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
}

.topbar-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

/* 字标：衬线 + 字距，报头感；不用色块方块 */
.brand-text {
  font-family: var(--font-serif);
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--ink);
}

.brand-sub {
  font-size: var(--fs-micro);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 主理人署名：头像 + 昵称（替代原先重复的「N 天」标签） */
.creator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.creator-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.creator-name {
  font-size: 13.5px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* 主题开关（v4）：胶囊轨道 + 滑动圆钮 —— 形态本身说明「可以切」
   用户反馈：原来是纯文字按钮，看不出是可切换控件。图标用内联 SVG（ux 规范：不用 emoji 当图标） */
.theme-switch {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.theme-switch:hover { border-color: var(--ink-3); }
.theme-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--canvas);
  transition: transform 0.18s var(--ease);
}
[data-theme="light"] .ts-thumb { transform: translateX(24px); }
.ts-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[data-theme="dark"] .ts-i-sun,
[data-theme="light"] .ts-i-moon { display: none; }

/* ---- 骨架：日期架 + 正文 --------------------------------------------------- */
.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 24px 72px;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* 日期架 */
.rail {
  position: sticky;
  top: 83px;
  padding: 32px 0 0;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: none;      /* 隐藏常驻滚动条：保持「线减法」，内容溢出仍可滚 */
}
.rail::-webkit-scrollbar { display: none; }

.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
}

.rail-label {
  font-family: var(--font-serif);
  font-size: var(--fs-small);
  color: var(--ink-2);
  letter-spacing: 0.06em;
}

/* 月份筛选框（v4）：按月份查往期，不再靠滚动找人 */
.rail-search {
  width: 100%;
  height: 34px;
  margin: 2px 0 10px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  transition: border-color 0.15s var(--ease);
}
.rail-search::placeholder { color: var(--ink-3); }
.rail-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.date-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

/* 选中态：颜色 + 字重 + 一个小圆点（不靠竖线/色块），符合 ux 规范「Active State 用颜色或下划线」 */
.date-list li { margin: 0; padding: 0; }

.d-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;                    /* 触控目标 ≥44px（移动端可点性） */
  padding: 10px 0 10px 16px;
  background: none;
  border: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: color 0.12s var(--ease);
}
.d-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.12s var(--ease);
}
.d-btn:hover { color: var(--ink-2); }
li.active > .d-btn {
  color: var(--ink);
  font-weight: 600;
}
li.active > .d-btn::before { opacity: 1; }
.d-date { flex: 1 1 auto; }
li.partial .d-date { color: var(--ink-3); }
.d-dot { font-size: 10px; color: var(--ink-3); opacity: 0.8; }

/* 月份分组（v4 可折叠）：点月头展开/收起；右侧月份数是信息，不作装饰用 */
.m-group { margin: 0; padding: 0; }
.m-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 40px;
  padding: 8px 0;
  background: none;
  border: 0;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s var(--ease);
}
.m-btn:hover { color: var(--ink); }
.m-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.m-chev {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
  transition: transform 0.18s var(--ease);
}
.m-group.open .m-chev { transform: rotate(90deg); }
.m-name { flex: 1 1 auto; }
.m-count { font-size: var(--fs-micro); color: var(--ink-3); }
.m-dates { list-style: none; margin: 0; padding: 0 0 4px 14px; }
.m-group:not(.open) .m-dates { display: none; }

/* 重试按钮：加载失败时给出下一步动作，而不是只报 HTTP 码 */
.retry-btn {
  margin-left: 10px;
  padding: 4px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--rounded-sm);
  background: none;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  cursor: pointer;
}
.retry-btn:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---- 正文 ------------------------------------------------------------------ */
.content { padding-top: 40px; min-width: 0; }

.content.enter > * { animation: rise 0.34s var(--ease) both; }
.content.enter > *:nth-child(2) { animation-delay: 0.04s; }
.content.enter > *:nth-child(3) { animation-delay: 0.08s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .content.enter > * { animation: none; }
}

.state {
  color: var(--ink-3);
  font-size: var(--fs-small);
  padding: 8px 0;
}

/* 报头：日期 + 三赛道图例 */
.brief-head {
  padding-bottom: 8px;
}

.date {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.date-cn {
  font-family: var(--font-serif);
  font-size: var(--fs-masthead);
  line-height: var(--lh-tight);
  letter-spacing: 0.01em;
  font-weight: 600;
  margin: 0;          /* h1 语义化后归零默认外边距 */
  display: block;
}

.date-week {
  font-size: var(--fs-small);
  color: var(--ink-3);
  letter-spacing: 0.1em;
}

/* 三色图例已并入赛道标题（颜色只出现在实际用到它的地方） */
.chip {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: 0.18em;
}
.track.lane-1 .chip { background: var(--gold); }
.track.lane-2 .chip { background: var(--teal); }

.meta { margin-top: 14px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--hover-bg);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.badge-quiet { background: transparent; }

/* 今日要点：导语体，比正文大一档 */
.lead-label {
  margin-top: 26px;
  font-family: var(--font-serif);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.1em;
}

.points {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 74ch;
}
.points li {
  position: relative;
  padding-left: 22px;
  font-size: var(--fs-lead);
  line-height: 1.65;
  color: var(--ink);
}
.points li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* GitHub 星标（v4）：实心简化星 + 数量，不再重复「GitHub」字样（栏目名已说明来源） */
.gh-stars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  font-size: var(--fs-small);
  color: var(--ink-3);
  white-space: nowrap;
  vertical-align: middle;
}
.gh-star {
  width: 13px;
  height: 13px;
  fill: currentColor;
  opacity: 0.9;
}

/* 缺板块提示：淡底块，不加线 */
.notice {
  margin: 22px 0;
  padding: 12px 14px;
  background: var(--note-bg);
  border-radius: var(--radius-ctl);
  font-size: var(--fs-small);
  color: var(--ink-2);
}

/* 赛道段落（v4）：改用「卡片」承载赛道身份 —— 用户反馈不要竖线/横线装饰。
   赛道色改由标题旁 chip + 卡片浅底表达（lane 映射仍与页眉图例一致，是信息不是装饰） */
.track {
  margin-top: 36px;
  padding: 22px 24px 24px;
  border: 1px solid var(--hairline-soft);
  border-radius: 16px;
  background: var(--surface-2);
  box-shadow: var(--shadow-top);
}
.track.lane-0 { background: color-mix(in srgb, var(--accent) 5%, var(--surface-2)); }
.track.lane-1 { background: color-mix(in srgb, var(--gold) 7%, var(--surface-2)); }
.track.lane-2 { background: color-mix(in srgb, var(--teal) 7%, var(--surface-2)); }

.track h2 {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: var(--fs-track);
  line-height: var(--lh-tight);
  letter-spacing: 0.02em;
  font-weight: 600;
}

/* 间距刻度：段内 8 < 段间 22 < 板块 40（避免全页均质松） */
.group { margin-top: 22px; }
.group:first-of-type { margin-top: 0; }

.group-title {
  font-size: var(--fs-micro);
  color: var(--ink-2);
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.item { margin-bottom: 14px; }
.item:last-child { margin-bottom: 0; }

.item-body { color: var(--ink); max-width: 74ch; }

.item-meta {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--hover-bg);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

/* 落地行动 = 主理人笔记：靠底色区分，不加额外竖线（避免与赛道色脊叠成双层线） */
.group[data-kind="actions"] {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--note-bg);
  border-radius: var(--radius-ctl);
}
.group[data-kind="actions"] .group-title { color: var(--gold); }
.group[data-kind="actions"] .item-body { font-size: var(--fs-small); line-height: 1.72; }

/* 共识 / 分歧 */
.viewpoint {
  margin-top: 40px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.vp-card {
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--radius-ctl);
}
/* 顶部细色条：共识=电光蓝、分歧=暖金（颜色是有含义的区分，不是装饰线） */
.vp-card::before {
  content: "";
  display: block;
  width: 28px;
  height: 2px;
  margin-bottom: 12px;
  background: var(--accent);
}
.vp-division::before { background: var(--gold); }

.vp-card h4 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 17px;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.vp-text { font-size: var(--fs-small); line-height: 1.75; color: var(--ink-2); max-width: 72ch; }

.vp-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: var(--fs-small);
  color: var(--ink-3);
}
.vp-card li { margin-bottom: 4px; }

/* 推荐阅读 / GitHub 项目推荐 */
.reading { margin-top: 40px; }

.reading h2 {
  margin: 0 0 18px;
  font-family: var(--font-serif);
  font-size: var(--fs-track);
  letter-spacing: 0.02em;
  font-weight: 600;
}

.reading ol {
  margin: 0;
  padding-left: 0;
  list-style: none;
  counter-reset: reading;
}

.reading > ol > li {
  position: relative;
  counter-increment: reading;
  padding: 0 0 22px 30px;
}
.reading > ol > li:last-child { padding-bottom: 0; }
.reading > ol > li::before {
  content: counter(reading);
  position: absolute;
  left: 0;
  top: 2px;
  width: 20px;
  font-family: var(--font-serif);
  font-size: var(--fs-small);
  color: var(--ink-3);
  text-align: right;
}

.reading a { font-weight: 500; }

.src {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--hover-bg);
  font-size: var(--fs-micro);
  color: var(--ink-3);
  white-space: nowrap;
}

/* 推荐理由 / 落地说明：靠字号与颜色降级，不加竖线 */
.reason {
  margin: 6px 0 0;
  font-size: var(--fs-small);
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 72ch;
}
.reason-why { color: var(--ink-3); }

/* ---- 页脚 ------------------------------------------------------------------ */
.footer {
  padding: 8px 24px 48px;
}

.footer-main,
.footer-note {
  max-width: var(--shell-max);
  margin: 0 auto;
  font-size: var(--fs-micro);
  line-height: 1.8;
  color: var(--ink-3);
}

.footer-main strong { color: var(--ink-2); font-weight: 600; }
.footer-note { margin-top: 8px; }
.footer-note:empty { display: none; }

/* ---- 窄屏：日期架转为横向时间轴 -------------------------------------------- */
@media (max-width: 860px) {
  :root { --fs-masthead: 30px; --fs-track: 21px; --fs-lead: 17.5px; }

  .topbar-inner { padding: 10px 16px; gap: 10px; }
  .brand-sub { display: none; }

  .shell {
    display: block;
    padding: 0 16px 56px;
  }

  .rail {
    position: sticky;
    top: 57px;
    z-index: 4;
    margin: 0 -16px;
    padding: 8px 20px 10px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    background: color-mix(in srgb, var(--canvas) 94%, transparent);
    backdrop-filter: blur(8px);
    /* 两端淡出：提示「右侧还有更早的期」 */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 26px), transparent 100%);
  }

  .rail-head { display: none; }

  /* 移动端：日期架仍是横向滑动条 —— v4 的月份分组在这里「展开成扁平」
     （display:contents 让月份头与嵌套列表不再产生层级，日期项直接成为横条的子项） */
  .rail-search {
    width: 100%;
    height: 32px;
    margin: 0 0 8px;
  }
  .m-group { display: contents; }
  .m-group[hidden] { display: none; }
  .m-btn { display: none; }
  .m-dates,
  .m-group:not(.open) .m-dates { display: contents; }

  .date-list {
    display: flex;
    gap: 4px;
    margin: 0;
    width: max-content;
  }

  .d-btn {
    width: auto;
    min-height: 44px;
    padding: 10px 12px;
    white-space: nowrap;
  }
  /* 横向排列时不放圆点，靠颜色 + 字重区分当前期 */
  .d-btn::before { display: none; }

  .content { padding-top: 22px; }
  .track { padding: 18px 16px 20px; border-radius: 14px; }
  .track,
  .viewpoint,
  .reading { margin-top: 34px; }

  .reading > ol > li { padding-left: 28px; }
}
