/* ============================================================
   观墨窗刊头（B5 v2 刀①，2026-07-28）— 效果权威 =
   docs/mockups/B5_SCROLL_THREAD_v2.html 幕一/二/三。
   两态常驻：guest = TEXTMOLT 大字；署名 = EX LIBRIS · 名 + 书签带（往卷）。
   2px 玄墨墨线 + 门楣签（免费藏书阁/藏书阁，entitlement 只读投影）。
   底 = 纸面 token 族（亮暗自适配）；thread 在墨线下滚动、没入刊头之后。
   ============================================================ */

:root {
  /* 墨线下缘对位（mast-row 18+~21 + rule 上距 9 + 2px 线）：
     文献库场景态面板顶用它贴线（zotero.css 消费） */
  --mast-rule-bottom: 50px;
}

/* 杀掉旧玻璃时代的滚动白纱层（system.css .header::after：0.72 白+saturate 会把
   纸面洗成中性——亮档掉暖、暗档掉紫，顶栏与聊天区割裂的根因，k5 探针实证
   Δ(+8,+11,+15)）；刊头本就是不透明纸面，分界只由 2px 墨线承担。id 选择器
   压过 system.css 的后加载同权规则 */
#ink-masthead::after {
  content: none;
}

.ink-masthead {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  height: auto;
  min-height: var(--header-height);
  padding: 0;
  /* 不透明纸面：会话滚动时消息从墨线下没入刊头之后（幕三「thread 在墨线下滚动」） */
  background:
    linear-gradient(var(--tm-paper-veil), var(--tm-paper-veil)),
    var(--tm-paper-texture) var(--tm-paper);
  background-size: auto, 300px 300px;
}

.mast-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--tm-space-2);
  padding: 18px 22px 0;
}

/* guest 大字位 = TEXTMOLT（用户拍板恢复）：衬线 700、0.22em 宽字距 */
.mast-brand {
  font-family: var(--tm-serif);
  font-weight: var(--tm-weight-semibold);
  font-size: 13.5px;
  letter-spacing: 0.22em;
  color: var(--tm-paper-ink);
  white-space: nowrap;
}
.mast-brand.hidden { display: none; }

/* 署名位 = EX LIBRIS · 名（名字斜体，藏书票紫墨）；
   长名（EN 更宽字距）只截名字段出省略号，「EX LIBRIS ·」前缀恒完整（真机 D7 修） */
.mast-exlibris {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--tm-serif);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: var(--tm-paper-exlibris);
  white-space: nowrap;
  /* ⚠️ 别再写 min-width:0（0815 真机 63-narrow-header-overlap 根因）:它关掉 flex
     地板后本盒被压得比「EX LIBRIS ·」还窄,前缀是匿名文本节点、自身不裁 → 溢出去
     盖在日期上(270px+空名+英文长日期实测压 5px)。主修法 = 日期先让位(见 .mast-date
     flex-shrink);overflow:hidden 只是兜底(它本身会把 flex 自动最小尺寸归零,靠不住) */
  overflow: hidden;
}
.mast-exlibris i,
.mast-exlibris .mast-exlibris-name {
  font-style: italic;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.mast-exlibris.hidden { display: none; }

/* 场景名（文献库态大字位）：与 TEXTMOLT 同形制 */
.mast-scene {
  font-family: var(--tm-serif);
  font-weight: var(--tm-weight-semibold);
  font-size: 13.5px;
  letter-spacing: 0.22em;
  color: var(--tm-paper-ink);
  white-space: nowrap;
}
.mast-scene.hidden { display: none; }

.mast-date {
  /* 窄栏日期让位（0813 真机 ≤283px 实证：flex:none 顶溢视口致撞字/裁箭头）；署名前缀恒完整。
     0815 加权重 100：日期是本行唯一可省的信息，缩量几乎全压它，署名盒才不被压穿 */
  flex: 0 100 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--tm-serif);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--tm-paper-ink-mut);
  white-space: nowrap;
}

/* 2px 玄墨墨线（报刊 masthead rule） */
.mast-rule {
  border: 0;
  border-top: 2px solid var(--tm-paper-ink);
  margin: 9px 22px 0;
}

/* 墨线下行：临时会话徽标（左）+ 门楣签（右）；书签带的定位锚 */
.mast-underrule {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--tm-space-2);
  padding: 6px 22px 8px;
  min-height: 26px;
}
.mast-underrule .temp-chat-badge {
  margin-right: auto;
}

.mast-shelf-link {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--tm-paper-ink-2);
  transition: color var(--tm-dur-fast) var(--tm-ease-out);
}
.mast-shelf-link:hover { color: var(--tm-ink-purple-strong); }
.mast-shelf-link.hidden { display: none; }

/* 场景态（文献库）：门楣行整行收起——面板题签（ZOTERO+×）顶到墨线正下
   （zotero.css 以 --mast-rule-bottom 对位面板顶）；
   顶线右侧 = 场景工具位顶替日期（引用样式签，用户 0728） */
.ink-masthead.mast-scene-mode .mast-underrule { display: none; }
.ink-masthead.mast-scene-mode { min-height: var(--mast-rule-bottom); }
.mast-tools { position: relative; display: none; }
.ink-masthead.mast-scene-mode .mast-date { display: none; }
.ink-masthead.mast-scene-mode .mast-tools { display: inline-flex; align-items: center; }

/* 书签带（往卷）：中世纪抄本丝质书签，紧咬墨线垂下、穿过门楣签行（真机 D8 修：
   锚改墨线正下方的 underrule 行顶，-1px 咬进墨线，不再悬空脱线） */
.mast-ribbon {
  position: absolute;
  left: 34px;
  top: -1px;
  width: 9px;
  height: 26px;
  padding: 0;
  border: 0;
  background: linear-gradient(180deg, var(--tm-paper-ink), var(--tm-paper-exlibris));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.13);
  cursor: pointer;
  z-index: var(--tm-z-raised);
  transition: height var(--tm-dur-fast) var(--tm-ease-out);
}
.mast-ribbon:hover { height: 30px; }
.mast-ribbon.hidden { display: none; }
/* 右滑面板（藏书阁/记忆）开启时书签带避让——书签带垂出刊头盒外，
   会盖到面板题签（真机 D3）；面板在场即收起，关面板即回 */
body:has(.cortex-panel:not(.hidden)) .mast-ribbon { display: none; }
