/* journal.css —— 05 会话日志 #journal（任务 7）。
   ≥768 横排：标签带全部在主线上方分两层交错（双数格上层、单数格下层，同层相邻间距 = 2×列距 − 签宽），
   中线行只有菱形与 ×5，线下一整段空白留给分支：分支从所选菱形中心直落轨道（起点 x、y 都在菱形中心），
   与任何标签、签、×5、其它菱形零相交且留 ≥4px。菱形中心用 round(down) 钉在整像素上。
   <768 竖排：一列九行，主线竖在 x=8，分支走廊 x=23–25（离菱形与内容各 ≥5px），短拐先进走廊再下行入轨道。
   静态标记 = 终态（R10）：全亮、选中「模型回复」、分支已画；分叉前后高度不变（轨道常驻 40px）。 */

/* 窗标题像素字（同 04：标题栏内容高 35，定 10px 顶距） */
#journal .win-title { align-self: flex-start; margin-block: 10px 0; display: flex; align-items: center; min-width: 0; }
#journal .win-title span { display: inline-block; vertical-align: top; }

/* ── 舞台：结点阵 + 主线；底部 40px 是分支轨道（常驻预留） ── */
#journal .jr-stage { position: relative; }
#journal .jr-nodes { position: relative; display: grid; grid-auto-rows: 28px; gap: 0; margin-bottom: 40px; }
#journal .jr-stage::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: auto; height: 224px; width: 2px; background: var(--line-2); }

/* 结点按钮（竖排一行）：菱形 + 标签 + 事件签 + ×5（行尾）；内容从 x=32 起，给分支走廊留位 */
#journal .jr-node { position: relative; display: flex; align-items: center; gap: 16px; padding: 0; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
#journal .jr-node:disabled { cursor: default; opacity: .55; }
#journal .jr-lab { flex: none; color: var(--text-4); font-size: 13px; line-height: 20px; }
#journal .jr-node.is-on .jr-lab { color: var(--text-3); }
#journal .jr-node[aria-checked="true"] .jr-lab { color: var(--text-1); }
@media (hover: hover) { #journal .jr-node:not(:disabled):hover .jr-lab { color: var(--text-1); } }
#journal .jr-x5 { flex: none; order: 4; margin-left: -8px; background: var(--surface); }
/* 竖排：两枚带 ×5 的签取整定宽，×5 才能落在整像素上（ch 按签自己的等宽字） */
#journal .jr-nodes .ev[data-ev="tool/call"] { width: calc(9ch + 10px); }
#journal .jr-nodes .ev[data-ev="tool/result"] { width: calc(11ch + 10px); }
@supports (width: round(1px, 1px)) {
  #journal .jr-nodes .ev[data-ev="tool/call"] { width: round(up, calc(9ch + 10px), 1px); }
  #journal .jr-nodes .ev[data-ev="tool/result"] { width: round(up, calc(11ch + 10px), 1px); }
}

/* 菱形：2px 方块拼的对称实心菱形（1/3/5/3/1 共 13 块，10×10 居中在 16px 宿主，中心 (8,8)）；
   ::after 自身那一格 = 上尖（left 7 / top 3），其余 12 块相对它的 box-shadow */
#journal .jr-dia { position: relative; flex: none; width: 16px; height: 16px; --dia: var(--line-3); }
#journal .jr-node.is-on .jr-dia { --dia: var(--accent); }
#journal .jr-node[aria-checked="true"] .jr-dia::before { content: ""; position: absolute; inset: -3px; border: 1px solid var(--text-3); }
#journal .jr-bd { position: relative; width: 16px; height: 16px; --dia: var(--accent); }
#journal .jr-dia::after, #journal .jr-bd::after {
  content: ""; position: absolute; left: 7px; top: 3px; width: 2px; height: 2px; background: var(--dia);
  box-shadow: -2px 2px 0 var(--dia), 0 2px 0 var(--dia), 2px 2px 0 var(--dia),
    -4px 4px 0 var(--dia), -2px 4px 0 var(--dia), 0 4px 0 var(--dia), 2px 4px 0 var(--dia), 4px 4px 0 var(--dia),
    -2px 6px 0 var(--dia), 0 6px 0 var(--dia), 2px 6px 0 var(--dia),
    0 8px 0 var(--dia); }

/* ── 分支层：静态终态可见（is-show 在「模型回复」那格） ── */
#journal .jr-branches { position: absolute; inset: 0; pointer-events: none; }
/* 格子用 opacity 而不是 visibility 隐藏：盒子仍在（内容本就 display:none），
   等分栅格审计按可见子元素量列缘时九格都算数 */
#journal .jr-br { opacity: 0; position: absolute; inset: 0; }
#journal .jr-br.is-show { opacity: 1; }
#journal .jr-br > * { display: none; }
#journal .jr-br.is-show > * { display: block; }
#journal .jr-br.is-show .jr-bd { display: none; }   /* 竖排的新菱形与签在轨道末端（jr-tail），不在格里 */
#journal .jr-br.is-show .jr-bc { display: none; }
#journal .jr-bs { position: absolute; width: 16px; height: 2px; background: var(--accent); }
#journal .jr-bl { position: absolute; width: 2px; background: var(--accent); }
/* 竖排分支几何：短拐（x8→24）+ 竖线沿走廊下到轨道，轨道里横拐 + 新菱形 + 签（坐标全整数） */
#journal .jr-bs { width: 18px; left: 8px; top: calc(var(--k) * 28px + 13px); }   /* 18px：拐角处与竖线叠出完整 2×2 外角 */
#journal .jr-bl { left: 23px; top: calc(var(--k) * 28px + 14px); height: calc(257px - var(--k) * 28px); }
#journal .jr-tail { display: block; }
#journal .jr-tj { position: absolute; left: 23px; top: 271px; width: 20px; height: 2px; background: var(--accent); }   /* 23–44：补外角并接到新菱形左尖 */
#journal .jr-td { position: absolute; left: 40px; top: 264px; }
#journal .jr-tc { position: absolute; left: 64px; top: 262px; }
#journal .jr-act { display: flex; margin: 0; }

/* ── 横排（≥768）：九列等分（累计取整，data-grid="even"）；标签带全在线上，线下留给分支 ── */
@media (min-width: 768px) {
  #journal .jr-stage::before { content: none; }
  #journal .jr-node::before { content: ""; position: absolute; top: 91px; left: -4px; right: -4px; height: 2px; background: var(--line-2); }
  #journal .jr-node:first-child::before { left: calc((100% - 16px) / 2 + 8px); }
  #journal .jr-node:last-child::before { right: calc(100% - ((100% - 16px) / 2 + 8px)); }
  @supports (width: round(1px, 1px)) {
    #journal .jr-node:first-child::before { left: calc(round(down, (100% - 16px) / 2, 1px) + 8px); }
    #journal .jr-node:last-child::before { right: calc(100% - (round(down, (100% - 16px) / 2, 1px) + 8px)); }
  }
  #journal .jr-nodes { --s: calc(100% - 64px); grid-auto-rows: auto; gap: 0 8px; margin-bottom: 40px; padding-inline: 16px;
    grid-template-columns: repeat(9, 1fr); }
  #journal .jr-branches { inset: 0 0 auto 0; height: 104px; display: grid; gap: 0 8px; padding-inline: 16px;
    --s: calc(100% - 64px); grid-template-columns: repeat(9, 1fr); }
  @supports (grid-template-columns: round(1px, 1px)) {
    #journal .jr-nodes, #journal .jr-branches { grid-template-columns:
      round(down, calc(var(--s) * 1 / 9 + .05px), 1px)
      calc(round(down, calc(var(--s) * 2 / 9 + .05px), 1px) - round(down, calc(var(--s) * 1 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 3 / 9 + .05px), 1px) - round(down, calc(var(--s) * 2 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 4 / 9 + .05px), 1px) - round(down, calc(var(--s) * 3 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 5 / 9 + .05px), 1px) - round(down, calc(var(--s) * 4 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 6 / 9 + .05px), 1px) - round(down, calc(var(--s) * 5 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 7 / 9 + .05px), 1px) - round(down, calc(var(--s) * 6 / 9 + .05px), 1px))
      calc(round(down, calc(var(--s) * 8 / 9 + .05px), 1px) - round(down, calc(var(--s) * 7 / 9 + .05px), 1px))
      minmax(0, 1fr); }
  }
  /* 五行：双数格 标签 0-20 / 签 20-40；单数格 标签 40-60 / 签 60-80；中线行 80-104（菱形 84-100） */
  #journal .jr-node { display: grid; grid-template-rows: 20px 20px 20px 20px 24px; grid-template-columns: minmax(0, 1fr);
    gap: 0; justify-items: center; align-items: center; height: 104px; }
  #journal .jr-node:nth-child(odd) .jr-lab { grid-row: 3; }
  #journal .jr-node:nth-child(odd) .ev { grid-row: 4; }
  #journal .jr-node:nth-child(even) .jr-lab { grid-row: 1; }
  #journal .jr-node:nth-child(even) .ev { grid-row: 2; }
  #journal .jr-dia { grid-row: 5; justify-self: start; margin-left: calc((100% - 16px) / 2); }
  #journal .jr-x5 { position: absolute; margin: 0; left: calc((100% - 16px) / 2 + 20px); top: 82px; }
  @supports (width: round(1px, 1px)) {
    #journal .jr-dia { margin-left: calc(round(down, (100% - 16px) / 2, 1px)); }
    #journal .jr-x5 { left: calc(round(down, (100% - 16px) / 2, 1px) + 20px); }
  }
  /* 分支：起点 = 菱形中心（stub 2×2），竖线直落轨道里的新菱形（120-136），签在其右 */
  #journal .jr-br { position: relative; inset: auto; height: 104px; --c: calc((100% - 16px) / 2 + 8px); }
  @supports (width: round(1px, 1px)) {
    #journal .jr-br { --c: calc(round(down, (100% - 16px) / 2, 1px) + 8px); }
  }
  #journal .jr-br.is-show .jr-bs { display: block; position: absolute; left: calc(var(--c) - 1px); top: 91px; width: 2px; height: 2px; }
  #journal .jr-bl { left: calc(var(--c) - 1px); top: 93px; height: 31px; }
  #journal .jr-br.is-show .jr-bd { display: block; position: absolute; left: calc(var(--c) - 8px); top: 120px; }
  #journal .jr-br.is-show .jr-bc { display: inline-flex; position: absolute; left: calc(var(--c) + 16px); top: 118px; }
  #journal .jr-br:nth-child(9).is-show .jr-bc { left: auto; right: calc(var(--c) + 16px); }   /* 末列签在左，不出界 */
  #journal .jr-tail { display: none; }
}

/* ── 计数与三条要点 ── */
#journal .jr-count { display: flex; align-items: baseline; gap: 10px; margin: 32px 0 0; }
#journal .jr-count [data-pxm] { font-size: 24px; line-height: 32px; color: var(--accent); }
#journal .jr-count span:last-child { color: var(--text-2); font-size: 15px; line-height: 24px; }
#journal .jr-facts { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 32px 0 0; padding: 0; list-style: none; }
@media (min-width: 768px) {
  #journal .jr-facts { --s: calc(100% - 48px); grid-template-columns: repeat(3, 1fr); gap: 24px; }
  @supports (grid-template-columns: round(1px, 1px)) {
    #journal .jr-facts { grid-template-columns:
      round(down, calc(var(--s) * 1 / 3 + .05px), 1px)
      calc(round(down, calc(var(--s) * 2 / 3 + .05px), 1px) - round(down, calc(var(--s) * 1 / 3 + .05px), 1px))
      minmax(0, 1fr); }
  }
}
#journal .jr-facts p { margin-top: 6px; color: var(--text-3); font-size: 14px; line-height: 22px; text-wrap: pretty; }
