/* ============================================================
   Design History Learning Environment · Demo v2
   视觉总纲：单一主题——探索模式为深色沉浸（图谱在暗底上发光）。
   主题 token 仍按 body[data-mode] 取值，当前只有 explore 一种。
   强调色语义：
     --accent      选中 / 当前 Context / AI 唤起（强）；深色模式下换同色相的亮变体
     --accent-weak AI 唤起（弱，同色系降强度）
     --personal    我的网络（线型 + 小型标记为主，颜色为辅）
   主题 token：
     --surface     抬升面（卡片 / 浮层 / 按钮底）——浅色 #fff，深色近黑灰
     --on-ink      压在 --ink 底上的文字（浅色 #fff，深色近黑）
     --on-accent   压在 --accent 底上的文字（随 accent 明暗互换）
     --glass       毛玻璃浮层底色（顶栏 / 工具层 / 把手）
     --node-fill   节点圆填充（浅底黑子 / 深底亮子，JS 连线端点同色）
     --canvas-dot  画布点阵（CSS 径向点 + SVG #dot-grid 共用）
   ============================================================ */

:root {
  /* 默认 token（浅色）：未命中 body[data-mode] 时使用 */
  --bg: #ffffff;
  --panel: #f8f7f5;
  --panel-2: #f2f1ee;
  --surface: #ffffff;
  --ink: #1c1c1c;
  --ink-2: #55524d;
  /* 10px 小字用色：需在 --bg/--panel/--panel-2 三种底上均达 AA 正文 4.5:1。
     原 #8a867f 实测 3.62 / 3.38 / 3.21，且承担 51 处 10px 文本（含模式切换器）。 */
  --ink-3: #726d66;
  --line: #e6e4e0;
  --line-strong: #cfccc5;
  --accent: #3d5a80;
  --accent-soft: rgba(61, 90, 128, 0.09);
  --accent-line: rgba(61, 90, 128, 0.55);
  --accent-weak: rgba(61, 90, 128, 0.35);
  --on-accent: #ffffff;
  --personal: #4e7d72;
  --personal-soft: rgba(78, 125, 114, 0.1);
  --on-ink: #ffffff;
  --glass: rgba(255, 255, 255, 0.94);
  --node-fill: #26241f;
  --canvas-dot: rgba(28, 28, 28, 0.05);
  --canvas-glow: transparent;
  /* 时间轴底缘栏（浅色 token）= 外亮内暗——轨道用暖浅灰，窗口段（选取范围内）用深炭斜纹 */
  --tl-track: #eae6de;
  --tl-window: repeating-linear-gradient(45deg, #43423d 0 3px, #4b4a44 3px 6px);
  --shadow-float: 0 8px 24px rgba(28, 28, 28, 0.14);
  --shadow-thumb: 0 1px 3px rgba(28, 28, 28, 0.24);
  --shadow-flood: #1c1c1c;
  --shadow-flood-opacity: 0.1;
  /* 浮层遮罩：半透明近黑，只压暗知识网络区。 */
  --overlay-scrim: rgba(10, 11, 13, 0.52);
  --radius: 8px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  /* ---------- §2.1.4 字距刻度 ----------
     量纲：Apple HIG 那列 tracking 的单位是 **pt（1x 下即 px）**，不是 em。
     §2.1.4 表中字号写 px，同表的字距即同口径；此前实现一律写成 em，
     在 26px 上把 +0.22 放大成 5.72px（26 倍），是「大标题字距失控、中文破折号被撑开」的根因。
     角色档（px）——只用于 §2.1.4 有对应角色的文字；CJK 字形本身接近满格，该值影响极小，
     不要为了「看得出效果」把它改成 em。 */
  --tracking-large-title: 0.22px;   /* largeTitle 26px */
  --tracking-title2: -0.43px;       /* title2 17px · 面板标题 */
  --tracking-title3: -0.23px;       /* title3 15px · 次级标题 */
  --tracking-body: 0.06px;          /* body 13px · 正文基准 */
  --tracking-subheadline: 0.06px;   /* subheadline 11px · 次要标签 */
  --tracking-caption: 0.12px;       /* caption1 10px · 说明文字 / 节点副行 */
  /* 标签档（em）——§2.1.4 的**书面例外**：全大写拉丁小标（eyebrow / section-number /
     各类 tag）在 Apple 的角色表里没有对应项。小字用正字距拉开是通用排版惯例
     （taste-skill「positive tracking for small caps or labels」），故单列一族、按 em 缩放。
     6 个在用的字面量收敛为 4 档，最大偏移 0.02em。 */
  --tracking-label-tight: 0.08em;   /* 密集 tag、中文时期名 */
  --tracking-label: 0.12em;         /* tag / caption 级小标（原 0.10、0.12） */
  --tracking-label-wide: 0.14em;    /* 小标基准（组件里最常用） */
  --tracking-label-xwide: 0.16em;   /* 全大写拉丁 eyebrow / 面板竖排（原 0.16、0.18） */
  --ease-out: cubic-bezier(0.22, 0.8, 0.3, 1);
  color-scheme: light;
}

/* 探索模式（深色）：冷灰族 + 单一低饱和蓝强调；不用纯黑；
   文字对比全部 ≥ 4.5:1（--ink-3 辅助色 10px 文本亦达标，回应 OQ-22③） */
body[data-mode="explore"] {
  --bg: #141518;
  --panel: #1c1d21;
  --panel-2: #242529;
  --surface: #1f2025;
  --ink: #eceded;
  --ink-2: #b6b7bb;
  --ink-3: #909197;
  --line: #2b2c31;
  --line-strong: #3c3d44;
  --accent: #7ea0c8;
  --accent-soft: rgba(126, 160, 200, 0.15);
  --accent-line: rgba(126, 160, 200, 0.55);
  --accent-weak: rgba(126, 160, 200, 0.4);
  --on-accent: #141518;
  --personal: #6faaa0;
  --personal-soft: rgba(111, 170, 160, 0.16);
  --on-ink: #141518;
  --glass: rgba(20, 21, 24, 0.88);
  --node-fill: #e9e7e2;
  --canvas-dot: rgba(236, 237, 237, 0.07);
  --canvas-glow: rgba(126, 160, 200, 0.06);
  /* 时间轴底缘栏：轨道贴近 histography 的 #303438 深炭，窗口亮窗用冷蓝灰斜纹 */
  --tl-track: #303438;
  --tl-window: repeating-linear-gradient(45deg, #46545f 0 3px, #53626e 3px 6px);
  --shadow-float: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-thumb: 0 1px 3px rgba(0, 0, 0, 0.55);
  --shadow-flood: #000000;
  --shadow-flood-opacity: 0.35;
  --overlay-scrim: rgba(10, 11, 13, 0.52);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.7;
  /* §2.1.4 body 角色 = +0.06（px 口径）。值极小但必须落到源码，
     否则该 token 是死的、规范那列字距不可稽核。带自己 letter-spacing 的元素会覆盖它。 */
  letter-spacing: var(--tracking-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* 表单控件统一继承排版。
   UA 默认会给 button/input/select/textarea 兜底 Arial + 13.3333px（10pt），
   该值不在 7 档字号刻度内——.panel-handle 与三个 composer 输入框此前都落在它上面。 */
button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- §2.4 内联 SVG 图标 ----------
   尺寸随所在元素的 font-size（1em）；着色只改 color（图元内部为 currentColor）。
   精灵容器不渲染，只承载 <symbol> 定义。 */
.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex: none;
  color: inherit;
}
svg.icon {
  fill: none;
}

/* ---------- 应用骨架 ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app.is-loading .workspace {
  opacity: 0.3;
  pointer-events: none;
}

/* ---------- 顶部 on-demand 工具区 ---------- */

.top-hotzone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 26px;
  z-index: 25;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 20px 12px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transform: translateY(-102%);
  transition: transform 0.32s var(--ease-out);
}

.topbar.is-open {
  transform: translateY(0);
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: var(--tracking-label-xwide);
  color: var(--ink-3);
  white-space: nowrap;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: var(--tracking-title3);
  white-space: nowrap;
}

.course-tag {
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0px 8px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-button {
  font-size: 11px;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  transition: border-color 0.2s, color 0.2s;
}

.top-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.demo-note {
  font-size: 10px;
  color: var(--ink-3);
  margin-left: 8px;
  white-space: nowrap;
}

/* ---------- 主工作区 ---------- */

.workspace {
  --ai-width: clamp(460px, 44vw, 760px);
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: var(--ai-width) 9px minmax(0, 1fr);
  min-height: 0;
  transition: grid-template-columns 0.28s var(--ease-out);
}

.workspace.is-resizing {
  transition: none;
  cursor: col-resize;
  user-select: none;
}

/* AI 面板合上：只展示知识网络 */
.workspace.ai-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.workspace.ai-collapsed .ai-workspace,
.workspace.ai-collapsed .workspace-divider {
  display: none;
}
.workspace.ai-collapsed .knowledge-workspace {
  border-right: none;
}

/* ---------- 左侧 on-demand 工具层 ---------- */

.left-hotzone {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 14px;
  z-index: 25;
}

.left-util {
  position: fixed;
  top: 50%;
  left: 0;
  z-index: 10;
  width: 218px;
  transform: translate(-106%, -50%);
  transition: transform 0.32s var(--ease-out);
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-float);
  padding: 12px 16px 12px 32px;
}

.left-util.is-open {
  transform: translate(0, -50%);
}

.util-title {
  margin: 12px 0 4px;
  font-size: 10px;
  letter-spacing: var(--tracking-label-wide);
  color: var(--ink-3);
}

.util-title:first-child {
  margin-top: 0;
}

.util-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  padding: 3px 0;
  cursor: pointer;
}

.util-check input {
  accent-color: var(--accent);
}

.util-badge {
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: var(--personal);
  border-radius: 999px;
  padding: 0 6px;
  line-height: 16px;
}

.util-button {
  width: 100%;
  text-align: left;
  margin-top: 4px;
}

/* ---------- Knowledge Workspace ---------- */

.knowledge-workspace {
  order: 3;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}

.kw-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px 8px;
}

.section-number {
  margin: 0 0 0px;
  font-size: 10px;
  letter-spacing: var(--tracking-label-xwide);
  color: var(--ink-3);
}

.kw-head h2, .ai-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: var(--tracking-title2);
}

.kw-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.legend {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--ink-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-shape {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.4px solid var(--ink-2);
}

.person-shape {
  border-radius: 50%;
}
.organization-shape {
  border-radius: 4px;
}
.object-shape {
  border-radius: 0;
}
.concept-shape {
  width: 13px;
  border-radius: 4px;
}

/* 图例：圆圈大小 = 重要程度 */
.legend i.size-hero, .legend i.size-major, .legend i.size-standard {
  border-radius: 50%;
  background: var(--surface);
}
.legend i.size-hero {
  width: 14px;
  height: 14px;
}
.legend i.size-major {
  width: 10px;
  height: 10px;
}
.legend i.size-standard {
  width: 7px;
  height: 7px;
}
.legend i.size-personal {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border-style: dashed;
  border-color: var(--personal);
}

#graph-count {
  margin: 0;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 网络画布 ---------- */

.network-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: radial-gradient(circle at 1px 1px, var(--canvas-dot) 1px, transparent 0) 0 0 / 26px 26px,
    radial-gradient(1200px 620px at 50% 42%, var(--canvas-glow), transparent 70%), var(--bg);
}

.network-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.graph-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

.graph-svg.is-panning {
  cursor: grabbing;
}

.graph-svg text {
  font-family: var(--font);
  user-select: none;
}

/* 加载与错误 */

.data-loading, .data-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--glass);
  text-align: center;
  padding: 0 32px;
}

.data-loading span {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-bottom: 4px;
}

@keyframes spin { to {
  transform: rotate(360deg);
} }

.data-loading strong, .data-error strong {
  font-size: 13px;
  font-weight: 600;
}
.data-loading small, .data-error p {
  font-size: 12px;
  color: var(--ink-3);
  max-width: 420px;
}
.data-error strong {
  color: #a34a3a;
}

/* 节点与关系样式：shared/node-system.css */

/* ---------- 缩放与显示控制 ---------- */

.zoom-controls {
  position: absolute;
  right: 14px;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  z-index: 6;
}

.zoom-controls button {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  transition: background 0.2s;
}

.zoom-controls button:hover {
  background: var(--panel-2);
}

#zoom-reset {
  font-size: 11px;
  padding: 0 8px;
}

#zoom-level {
  font-size: 10px;
  color: var(--ink-3);
  min-width: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.display-controls {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 4px;
  z-index: 6;
}

.toggle-button {
  font-size: 11px;
  color: var(--ink-3);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  transition: color 0.2s, border-color 0.2s;
}

.toggle-button:hover {
  color: var(--ink);
}

.toggle-button.is-active {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ---------- 画布节点搜索 ----------
   入口在画布左上常驻控件区（.display-controls），与三个药丸开关同一行、排在最前。
   收起态只有放大镜按钮；展开态是输入框加关闭按钮，宽度从 0 过渡到 220px。
   结果列表与悬停详情卡片是画布内的浮层：层级高于画布控件层（6）、低于图片浮层（.image-reader，60）。 */

.canvas-search {
  position: relative;
  display: flex;
  align-items: center;
}

.canvas-search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
}

.canvas-search.is-open .canvas-search-toggle {
  display: none;
}

.canvas-search-field {
  display: flex;
  align-items: center;
  width: 0;
  overflow: hidden;
  border: 0 solid transparent;
  border-radius: 999px;
  background: var(--glass);
  /* 收起态用 visibility 而非 display：宽度过渡要能演，同时输入框与「×」不成为隐藏的 Tab 停点。
     关闭时 visibility 延迟到宽度过渡结束再翻，避免收起瞬间消失。 */
  visibility: hidden;
  transition: width 0.24s var(--ease-out), visibility 0s linear 0.24s;
}

.canvas-search.is-open .canvas-search-field {
  width: 220px;
  border-width: 1px;
  border-color: var(--line);
  visibility: visible;
  transition: width 0.24s var(--ease-out), visibility 0s;
}

.canvas-search-field:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.canvas-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: var(--tracking-subheadline);
  color: var(--ink);
  padding: 3px 2px 3px 10px;
  outline: none;
}

.canvas-search-input::placeholder {
  color: var(--ink-3);
}

.canvas-search-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0 4px 0 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.canvas-search-close:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.canvas-search-close:active {
  background: var(--accent-soft);
}

.canvas-search-toggle:focus-visible,
.canvas-search-close:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 1px;
}

.canvas-search-results {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 12;
  width: 250px;
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
}

.canvas-search-empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--ink-3);
}

.canvas-search-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.canvas-search-item:hover,
.canvas-search-item.is-selected {
  background: var(--accent-soft);
}

.canvas-search-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
}

.canvas-search-meta {
  font-size: 10px;
  letter-spacing: var(--tracking-caption);
  color: var(--ink-3);
}

/* 未展开：目标节点当前不在画布上，跳转会先展开它的分支 */
.canvas-search-flag {
  flex: none;
  margin-left: auto;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: var(--tracking-caption);
  color: var(--ink-3);
}

/* 悬停详情卡片：与节点详情卡片同构——标题 / 副行 / 简介滚动区 + 主图列 + 缩略图列。
   宽、高与文字列宽由 JS 从 nodeSystem.detailMetrics() 写入；内边距、列距与图片尺寸
   与 shared/node-system.js 的详情卡常量一致（16 / 14 / 88 / 34 / 8）。
   卡片不参与指针命中：指针移到卡片上仍算离开条目，卡片随即收起。 */
.canvas-search-card {
  position: absolute;
  left: calc(100% + 8px);
  top: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 10px;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 3px;
  box-shadow: var(--shadow-float);
  pointer-events: none;
}

.canvas-search-card-row {
  display: flex;
  flex: 1;
  gap: 14px;
  min-height: 0;
}

.canvas-search-card-text {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.canvas-search-card-title {
  flex: none;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
  color: var(--ink);
}

.canvas-search-card-meta {
  flex: none;
  margin: 0;
  font-size: 10px;
  line-height: 14px;
  letter-spacing: var(--tracking-caption);
  color: var(--ink-3);
}

.canvas-search-card-desc {
  flex: 1;
  min-height: 0;
  margin-top: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.canvas-search-card-line {
  position: relative;
  height: 14px;
}

.canvas-search-card-line span {
  position: absolute;
  top: 0;
}

.canvas-search-card-line,
.canvas-search-card-line span {
  white-space: pre;
  font-size: 9px;
  line-height: 14px;
  color: var(--ink-2);
}

.canvas-search-card-media {
  align-self: flex-start;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--panel-2);
}

.canvas-search-card-hero {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.canvas-search-card-mono {
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 26px;
  color: var(--ink-3);
}

.canvas-search-card-thumbs {
  display: flex;
  flex: none;
  gap: 8px;
  height: 34px;
}

.canvas-search-card-thumb {
  width: 34px;
  height: 34px;
  border-radius: 2px;
  object-fit: cover;
}

.interaction-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  margin: 0;
  text-align: center;
  font-size: 10px;
  color: var(--ink-3);
  pointer-events: none;
  z-index: 4;
}

/* ---------- 时间轴 ---------- */

/* ---------- 时间轴（源码级仿照 histography.io 的 #footer 底缘时间栏） ----------
   收起态（默认）：20px 高底缘细条 = histography 的 #slider_container ——
   轨道（--tl-track）+ 图案窗口段（--tl-window，仿 .noUi-connect 的 slider_pattern）
   + 双圆柄；纯图形无文字（histography 收起态同样无文字）。
   轨道 / 窗口段按主题取值：探索 = 外暗内亮（深炭轨道 + 冷蓝灰亮窗）。
   展开态（.is-open / :focus-within，220px）：histography 的 #footer.open ——
   栏体以原值 cubic-bezier(.075,.96,.595,1.12) .7s 向上弹起（带回弹过冲），
   依次露出：时期行（仿 #periods，居中、小字大写、非活跃 30% 透明）→
   范围读数 → 时间刻度 → 贴柄年份标签（仿 #slider_years，
   斜体小字，与窗口两端居中对齐）→ 底部 20px 轨道位置不变。
   收起时机由 JS 控制：指针离开展开区域 500ms 后移除 .is-open
   （不再叠加 CSS transition-delay），.timeline-clip 负责收起态的裁切。 */

.timeline {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  z-index: 12;
  height: 20px;
  margin: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: none;
  box-shadow: var(--shadow-float);
  overflow: visible;
  transition: height 0.7s cubic-bezier(0.075, 0.96, 0.595, 1.12), background-color 0.45s var(--ease-out),
    border-color 0.45s var(--ease-out);
}

.timeline.is-open,
.timeline:focus-within {
  height: 220px;
}

.timeline-clip {
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* 展开面板（收起态被 clip 裁出 20px 视口） */
.timeline-panel {
  flex: 1 0 auto;
  padding: 10px 16px 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
}

/* 时期行：仿 histography #periods —— 居中横排、点状下沿、非活跃半透明。 */
.timeline-eras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  column-gap: 14px;
  row-gap: 4px;
  border-bottom: 1px dotted var(--line-strong);
  padding-bottom: 6px;
}

.timeline-eras button {
  font-size: 10px;
  letter-spacing: var(--tracking-label-tight);
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  opacity: 0.45;
  transition: opacity 0.25s, color 0.25s;
  white-space: nowrap;
}

.timeline-eras button:hover {
  opacity: 1;
  color: var(--ink);
}

.timeline-eras button.is-active {
  opacity: 1;
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

.timeline-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  padding-top: 4px;
}

#timeline-title {
  font-size: 10px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
}

#timeline-selection {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#timeline-status {
  margin: 0;
  font-size: 10px;
  color: var(--ink-3);
}

/* 滑轨壳：底部 20px 是常显轨道区，其上为刻度 / 年份标签 / you-are-here */
.range-shell {
  position: relative;
  flex: none;
  height: 74px;
}

/* 轨道 = histography #slider_container：20px 深色满条 */
.range-base {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 20px;
  border-radius: 4px 4px 0 0;
  background: var(--tl-track);
  opacity: 1;
}

/* 窗口段 = histography .noUi-connect：图案亮窗（斜纹，仿 slider_pattern.png） */
.range-active {
  position: absolute;
  bottom: 0;
  height: 20px;
  border-radius: 4px 4px 0 0;
  background: var(--tl-window);
  cursor: grab;
}

.range-active:active {
  cursor: grabbing;
}

/* 时间刻度：轨道正上方（收起态被裁掉） */
.range-ticks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  height: 12px;
}

.range-ticks span {
  position: absolute;
  top: 0;
  font-size: 10px;
  color: var(--ink-3);
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.range-ticks span::before {
  content: "";
  display: block;
  width: 1px;
  height: 3px;
  background: var(--line-strong);
  margin: 0 auto 1px;
}

/* 窗口两端年份标签：仿 histography #slider_years 的斜体小字，
   与可拖动窗口两端**居中对齐**（label 中心 = 端点位置） */
.range-years {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  height: 16px;
  pointer-events: none;
}

.range-years .ry {
  position: absolute;
  top: 0;
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateX(-50%);
  text-align: center;
}

.range-shell input[type="range"] {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  width: 100%;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
  height: 18px;
}

.range-shell input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  cursor: ew-resize;
  box-shadow: var(--shadow-thumb);
}

.range-shell input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--accent);
  cursor: ew-resize;
}

.you-are-here {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 3;
}

.you-are-here.is-on {
  opacity: 1;
}

.you-are-here i {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: -0.5px;
  width: 1px;
  background: var(--ink);
  opacity: 0.6;
}

.you-are-here b {
  position: absolute;
  bottom: 100%;
  left: 0;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- AI Workspace ---------- */

.ai-workspace {
  order: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
  border-right: 1px solid var(--line);
}

.ai-chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.ai-head {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--line);
}

.ai-title {
  min-width: 0;
}

.preset-row {
  padding: 4px 24px 8px;
  border-bottom: 1px solid var(--line);
}

.preset-questions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.preset-question {
  font-size: 11px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  transition: all 0.2s;
}

.preset-question:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Context Bar */

.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  min-height: 44px;
  flex-wrap: wrap;
}

.context-label {
  font-size: 10px;
  letter-spacing: var(--tracking-label-wide);
  color: var(--ink-3);
}

.context-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 2px 6px 2px 11px;
  transition: all 0.2s;
}

.context-chip.is-global {
  color: var(--ink-2);
  background: var(--panel);
  border-color: var(--line);
}

.context-chip .chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 0;
}

.context-chip .chip-x:hover {
  background: rgba(128, 128, 128, 0.28);
}

/* ---------- 对话区 ---------- */

.conversation {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px;
  scroll-behavior: smooth;
}

.ai-message, .user-message {
  margin-bottom: 20px;
}

.user-message {
  display: flex;
  justify-content: flex-end;
}

.user-message .message-body {
  max-width: 86%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px 8px 4px 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.7;
}

.ai-message .message-body {
  max-width: 100%;
}

.message-body > p {
  margin: 0 0 8px;
}
.message-body > p:last-child {
  margin-bottom: 0;
}

.message-body h4 {
  margin: 16px 0 4px;
  font-size: 12px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
  font-weight: 600;
}

/* 进入动画（逐条淡入） */
.message-enter {
  animation: msg-in 0.45s var(--ease-out);
}

/* ---------- 回答结构元素（与《回答规范》第五节配套） ---------- */
/* 正文列宽封顶：面板再宽，正文单行不超过约 40 字（660px），余量留白。
   对照表与相关对象卡片信息密度高，不受此限（由 compare-scroll 自行处理）。 */
.ai-message .message-body > p,
.ai-message .message-body > .range-extension,
.ai-message .message-body > h4.sec-title {
  max-width: 660px;
}

/* 结论框：首个 claim 是主旨句 */
.ai-message .message-body > p.lead-claim {
  border: 1px solid #33506e;
  background: #1b2130;
  border-left: 3px solid #3d5a80;
  border-radius: 8px;
  padding: 10px 13px;
}
.ai-message .message-body > p.lead-claim .lead-tag {
  display: inline-block;
  font-size: 11px;
  line-height: 1.6;
  color: #a8c4e0;
  border: 1px solid #33506e;
  border-radius: 999px;
  padding: 0 8px;
  margin-right: 8px;
  vertical-align: 1px;
}

/* 小节标题：模型以 "## " 开头的 claim */
.ai-message .message-body > h4.sec-title {
  margin: 18px 0 6px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-message .message-body > h4.sec-title::before {
  content: "";
  width: 4px;
  height: 14px;
  background: #3d5a80;
  border-radius: 2px;
  flex: none;
}

/* 紧凑事实列表：连续 "- " claim 合并渲染 */
.ai-message .message-body > .fact-list {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
}
.ai-message .message-body > .fact-list li {
  position: relative;
  padding: 5px 0 5px 16px;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  line-height: 1.7;
  max-width: 660px;
}
.ai-message .message-body > .fact-list li:last-child {
  border-bottom: 0;
}
.ai-message .message-body > .fact-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 14px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
}

/* 桌面端空间不足时历史列的浮层模式（JS 加 .is-overlay，见 app.js reconcileHistoryLayout） */
@media (min-width: 701px) {
  .ai-workspace {
    position: relative;
  }
  .chat-history-panel.is-overlay {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 30;
    width: 280px;
    box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--line);
  }
}

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

/* 生成指示 */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  font-size: 12px;
  padding: 4px 0px;
}

.typing-indicator svg {
  animation: spin 1s linear infinite;
}

/* 事实 / 解释区分 */

/* 比较表在窄栏（AI 对话列）里的横向滚动容器；单列情形不渲染表格（见 app.js） */
.compare-scroll {
  max-width: 100%;
  overflow-x: auto;
}

/* 候选关系里的新节点标记（AI 建议带来的、尚不在知识网络中的对象） */
.cand-new {
  margin-left: 6px;
  padding: 0 5px;
  border: 1px dashed var(--personal);
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  color: var(--personal);
}

/* 节点候选卡的内容块（类型年代 / 简介 / 将建立的关系） */
.candidate-card .cand-meta,
.candidate-card .cand-synopsis,
.candidate-card .cand-relations {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
}
.candidate-card .cand-synopsis { color: var(--ink-1); }
.candidate-card .cand-relations { color: var(--ink-3); }

.mark-fact {
  /* 不放下划线（2026-10-02 用户裁定）。**事实与解释的区分仍成立**：
     解释性内容整体包在 .interp-block 里（灰底 + 「历史解释 / 推断」标签），
     因此这里只保留语义类名，不再加装饰。 */
  padding-bottom: 0;
}

.interp-block {
  background: var(--panel);
  border-left: 2px solid var(--ink-3);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--ink-2);
}

.interp-block .interp-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: var(--tracking-label-tight);
  color: var(--ink-3);
  margin-bottom: 4px;
}

.mark-interp {
  color: var(--ink-2);
  border-bottom: 1.5px dashed var(--ink-3);
  padding-bottom: 0px;
}

/* 行内对象标记（inline object marker） */

.obj-link {
  display: inline;
  border: none;
  background: transparent;
  padding: 0 0px;
  font-size: inherit;
  font-family: inherit;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-weak);
  transition: background 0.2s;
  line-height: inherit;
}

.obj-link:hover {
  background: var(--accent-soft);
}

/* 来源标记（句子级） */

.source-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  margin: 0 0px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  vertical-align: 2px;
  transition: all 0.2s;
}

.source-marker:hover, .source-marker.is-open {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* 来源面板 */

.source-panel {
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.source-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.source-item:last-child {
  border-bottom: none;
}

.source-item .source-num {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  text-align: center;
  height: 16px;
  line-height: 15px;
  margin-top: 0px;
}

.source-item .source-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0px;
}

.source-item .source-meta {
  font-size: 10px;
  color: var(--ink-3);
  margin: 0 0 4px;
}

.source-item .source-excerpt {
  font-size: 11px;
  color: var(--ink-2);
  margin: 0;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.source-chip {
  display: inline-block;
  font-size: 10px;
  letter-spacing: var(--tracking-subheadline);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: 1px;
}

.source-chip.official {
  color: var(--accent);
  background: var(--accent-soft);
}
.source-chip.web {
  color: var(--ink-2);
  background: var(--panel-2);
}
.source-chip.unverified {
  color: #a34a3a;
  background: rgba(163, 74, 58, 0.08);
}

/* 范围外补充 */

.range-extension {
  margin: 8px 0;
  padding: 8px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.range-extension .re-tag {
  font-size: 10px;
  letter-spacing: var(--tracking-label-tight);
  color: var(--ink-3);
  display: block;
  margin-bottom: 0px;
}

/* 相关对象 */

.related-objects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 4px;
}

.related-object {
  font-size: 11px;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
  text-align: left;
  transition: all 0.2s;
}

.related-object:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}
.related-object small {
  display: block;
  font-size: 10px;
  color: var(--ink-3);
}

/* 比较表 */

.compare-grid {
  display: grid;
  grid-template-columns: 76px 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
  font-size: 12px;
}

.compare-grid > div {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.compare-grid > div:nth-last-child(-n+3) {
  border-bottom: none;
}

.compare-grid .cg-head {
  font-weight: 600;
  background: var(--panel);
}
.compare-grid .cg-axis {
  color: var(--ink-3);
  font-size: 11px;
  background: var(--panel);
}
.compare-grid .cg-cell {
  color: var(--ink-2);
}

/* Candidate Relation 卡片 */

.candidate-card {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
  background: linear-gradient(180deg, var(--surface), var(--panel));
}

.candidate-card .cand-tag {
  font-size: 10px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.candidate-chain {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}

.candidate-chain .cand-node {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
}

.candidate-chain .cand-pred {
  color: var(--ink-3);
  font-size: 11px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0px;
}

.candidate-chain .cand-pred::before, .candidate-chain .cand-pred::after {
  content: "";
  width: 1px;
  height: 7px;
  background: var(--line-strong);
}

.candidate-card .cand-evidence {
  font-size: 11px;
  color: var(--ink-3);
  margin: 0 0 8px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.candidate-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.candidate-actions button {
  font-size: 11px;
  border-radius: 8px;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  transition: all 0.2s;
}

.candidate-actions button:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.candidate-actions .cand-save {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.candidate-actions .cand-save:hover {
  background: color-mix(in srgb, var(--accent) 82%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 82%, var(--ink));
  color: var(--on-accent);
}

.candidate-card.is-saved {
  border-color: var(--personal);
}
.candidate-card.is-saved .cand-tag {
  color: var(--personal);
}

.save-toast {
  font-size: 11px;
  color: var(--personal);
  animation: msg-in 0.4s var(--ease-out);
}

/* ---------- Composer ---------- */

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 24px 12px;
}

.composer-label {
  display: block;
  font-size: 10px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
  margin-bottom: 4px;
}

.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px 4px 4px 6px;
  transition: border-color 0.2s;
}

.composer-row:focus-within {
  border-color: var(--accent-line);
}

.composer-tool {
  font-size: 10px;
  color: var(--ink-3);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}

.composer-tool:hover {
  color: var(--ink-2);
}

#question-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  min-width: 0;
}

#question-input::placeholder {
  color: var(--ink-3);
}

#send-question {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 13px;
  transition: background 0.2s;
  flex-shrink: 0;
}

#send-question:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.composer-status {
  margin: 4px 0px 0;
  font-size: 10px;
  color: var(--ink-3);
}

/* ---------- 响应式 ---------- */

@media (max-width: 1100px) and (min-width: 701px) {
  .workspace {
    --ai-width: clamp(390px, 46vw, 560px);
  }
  .kw-head {
    padding-left: 18px;
    padding-right: 18px;
  }
  .kw-meta .legend {
    display: none;
  }
  .network-shell {
    margin-left: 16px;
    margin-right: 16px;
  }
}

/* ============================================================
   图片层（histography 转译）
   - 节点圆像：hover / 选中时圆圈显现实体主图，白圈描边
   - 详情卡：大圆填充照片 + 方形白描边缩略图列
   - 图片详情浮层：知识网络区内的浮层卡片，固定 860×520，图与文并排
   ============================================================ */

/* ---------- 图片详情浮层 ----------
   定位：绝对定位于 .knowledge-workspace，水平垂直都居中。浮层不覆盖右侧 AI 对话面板。
   尺寸：固定 860×520。AI 面板开合与窗口缩放都不改变这个尺寸，
        只有可用宽高不足时才按可用值收缩。翻页换图时图格不动。
   重排：浮层内容宽 < 700px 时改为图在上、文字在下（容器查询）。 */

.image-reader {
  position: absolute;
  inset: 0;
  z-index: 60;
}

/* 遮罩：只压暗知识网络区，并在浮层位置开洞，让下层网络依稀可见。
   不使用模糊：模糊在本项目里只用于玻璃底（--glass + backdrop-filter）。 */
.reader-scrim {
  position: absolute;
  inset: 0;
  background: var(--overlay-scrim);
  -webkit-mask-image: radial-gradient(ellipse 62% 70% at 50% 46%, transparent 34%, #000 84%);
  mask-image: radial-gradient(ellipse 62% 70% at 50% 46%, transparent 34%, #000 84%);
}

.reader-panel {
  position: absolute;
  inset: 0;
  width: min(860px, 100% - 48px);
  height: min(520px, 100% - 120px);
  margin: auto;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.image-reader.is-entering .reader-panel {
  animation: reader-in 0.28s var(--ease-out);
}
.image-reader.is-entering .reader-hero img {
  animation: reader-image-in 0.45s var(--ease-out);
}
.image-reader.is-entering .reader-title {
  animation: reader-title-in 0.5s var(--ease-out);
}
.image-reader.is-entering .reader-sub,
.image-reader.is-entering .reader-text,
.image-reader.is-entering .reader-link {
  animation: reader-fade-in 0.5s var(--ease-out) 0.1s both;
}

@keyframes reader-in {
  from {
  opacity: 0;
  transform: translateY(14px);
}
  to {
  opacity: 1;
  transform: translateY(0);
}
}
@keyframes reader-image-in {
  from {
  opacity: 0;
  transform: scale(1.04);
}
  to {
  opacity: 1;
  transform: scale(1);
}
}
/* histography show_wiki：行距收拢的标题入场 */
@keyframes reader-title-in {
  from {
  opacity: 0;
  line-height: 3.2;
}
  to {
  opacity: 1;
  line-height: 1.15;
}
}
@keyframes reader-fade-in {
  from {
  opacity: 0;
  transform: translateY(6px);
}
  to {
  opacity: 1;
  transform: translateY(0);
}
}

/* 点线顶栏（histography dotted topbar） */
.reader-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
  border-bottom: 1px dotted var(--line-strong);
  flex-shrink: 0;
}
.reader-counter {
  font-weight: 700;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.reader-source {
  margin-left: auto;
}
.reader-close {
  border: none;
  background: none;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-2);
  padding: 0px 4px;
  border-radius: 8px;
}
.reader-close:hover {
  background: var(--panel-2);
  color: var(--ink);
}

/* 内容网格：窄时图在上、文字在下；宽时图左文右 */
.reader-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  grid-template-rows: minmax(0, auto) minmax(0, auto);
  align-content: center;
  gap: 16px 24px;
  padding: 16px 0 18px;
}
.reader-nav {
  display: flex;
  align-items: center;
  justify-content: center;
}
.reader-nav.is-prev {
  grid-column: 1;
  grid-row: 1 / -1;
}
.reader-nav.is-next {
  grid-column: 3;
  grid-row: 1 / -1;
}
.reader-step {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--ink-2);
  background: transparent;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.reader-step:hover {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--ink);
}

/* 焦点可见：契约声明的 focus-visible 状态。 */
.reader-close:focus-visible,
.reader-step:focus-visible,
.reader-entity-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 图片框：底色与浮层同色。图片按原图比例完整显示，不裁切、不拉伸。 */
.reader-hero {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.reader-hero img {
  display: block;
  /* 窄浮层里图占满整行，用上限压住高度：横图不挤掉下方文字，竖图不占满一屏。 */
  max-width: 100%;
  max-height: min(46vh, 300px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.reader-caption {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  padding: 0 2px;
}

/* 文字层级：主标题 = 当前图片的说明；副行 = 类型 · 史实时间；文字 = 实体简介；脚注 = 关联节点。
   主标题用《交互体验规范》§2.1.4 largeTitle 角色（26px / 400 / +0.22px）。 */
.reader-sub {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: var(--tracking-label-xwide);
  color: var(--ink-3);
}
.reader-title {
  margin: 0 0 12px;
  font-family: var(--font);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: var(--tracking-large-title);
  color: var(--ink);
}
/* 实体简介当前留空（负责人 2026-10-12）：没有内容时不占位。 */
.reader-text {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.9;
  color: var(--ink-2);
}
.reader-text:empty {
  display: none;
}
.reader-link {
  margin: 0;
  padding-top: 10px;
  border-top: 1px dotted var(--line-strong);
  font-size: 11px;
  color: var(--ink-3);
}
/* 实体简介留空时，脚注不画分隔线，避免出现一条孤立的横线。 */
.reader-caption.is-text-empty .reader-link {
  border-top: none;
  padding-top: 0;
}
/* 脚注里的实体名：行内按钮，点击关闭浮层并在画布上定位该节点。 */
.reader-entity-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-line);
}
.reader-entity-link:hover {
  border-bottom-color: var(--accent);
}
.reader-entity-link::after {
  content: " ↗";
  font-size: 9px;
  vertical-align: 1px;
}

/* 宽浮层：图左文右。图格固定 320px 宽，文字列取剩余宽度；
   窗口与 AI 面板变化时图格不动，因此翻页换图不会引起图与文字跳动。 */
@container (min-width: 700px) {
  .reader-body {
    grid-template-columns: 54px 320px minmax(0, 1fr) 54px;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    padding: 18px 0 20px;
  }
  .reader-nav.is-prev {
    grid-column: 1;
    grid-row: 1;
  }
  .reader-nav.is-next {
    grid-column: 4;
    grid-row: 1;
  }
  .reader-hero {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }
  .reader-hero img {
    max-width: 100%;
    max-height: 100%;
  }
  .reader-caption {
    grid-column: 3;
    grid-row: 1;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

/* ============================================================
   时间点阵 + 关系直线 + 面板把手（A1+ 方案）
   ============================================================ */

/* ---------- 两侧面板把手（固定可见，点击开合） ---------- */

.panel-handle {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  width: 22px;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0;
  background: var(--glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  transition: background 0.2s;
}
.panel-handle.is-left {
  left: 0;
  border-left: none;
  border-radius: 0 8px 8px 0;
}
/* 右把手：骑在左右两界面交界缝上，随知识工作区右缘定位 */
.panel-handle.is-right {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  border-radius: 8px;
}
.panel-handle:hover {
  background: var(--surface);
}

.panel-handle span {
  writing-mode: vertical-rl;
  font-size: 10px;
  letter-spacing: var(--tracking-label-xwide);
  color: var(--ink-2);
}
.panel-handle:hover span {
  color: var(--ink);
}

.panel-handle i {
  font-style: normal;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-3);
  transition: transform 0.3s var(--ease-out);
}
/* 左把手：合上面板后箭头朝右（可拉开），打开后朝左 */
.panel-handle.is-left.is-open i {
  transform: rotate(180deg);
}
/* AI 把手：面板打开时箭头朝左（可收起），收起后朝右（可展开） */
.panel-handle.is-right i {
  transform: rotate(180deg);
}
.panel-handle.is-right.is-collapsed i {
  transform: none;
}

/* ---------- 布局视图切换（点阵 / 图谱） ---------- */

.view-switch {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 0px 0 4px;
}
.view-switch button {
  flex: 1;
  font-size: 11px;
  padding: 4px 0;
  border: none;
  background: var(--surface);
  color: var(--ink-2);
  transition: all 0.2s;
}
.view-switch button + button {
  border-left: 1px solid var(--line);
}
.view-switch button:hover {
  color: var(--ink);
  background: var(--panel);
}
.view-switch button.is-active {
  background: var(--ink);
  color: var(--on-ink);
}

/* ============================================================
   圆圈变形详情卡 + 时代大标签
   ============================================================ */

/* 时间轴下的时代大标签（运动本身不作为节点；点击 +/- 展开/收起其人物与组织） */
.movement-caption {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 26px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.movement-caption:hover strong {
  color: var(--accent);
}

.mc-toggle {
  font-style: normal;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-3);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: none; /* 时间轴收起（默认）时隐藏 +；展开后随面板出现（见下方 :has 规则） */
  align-items: center;
  justify-content: center;
  line-height: 1;
  align-self: center;
  transition: all 0.2s;
}

/* 时间轴展开（指针热区 .is-open 或键盘 focus-within）时恢复 + 展开/收起钮 */
body:has(.timeline.is-open) .mc-toggle,
body:has(.timeline:focus-within) .mc-toggle {
  display: inline-flex;
}
.movement-caption:hover .mc-toggle {
  border-color: var(--accent);
  color: var(--accent);
}
.movement-caption.is-expanded .mc-toggle {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}
.movement-caption strong {
  /* §2.1.4 largeTitle 角色：26px / 400 / +0.22em。原为 Bodoni/Didot 衬线 + 700 + 0.08em，
     与「字体族：界面用现代无衬线」及 largeTitle 的字重/字距两轴均不符 */
  font-family: var(--font);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: var(--tracking-large-title);
  color: var(--ink);
}
.movement-caption span {
  /* §2.1.4 caption1 角色：10px / 400 / +0.12em（原 0.22em 误用了 largeTitle 的字距） */
  font-size: 10px;
  letter-spacing: var(--tracking-caption);
  color: var(--ink-3);
}

/* ---------- 来源浮层（点击句尾 [1][2] 圆点 / 「查看来源」按钮） ----------
   来源不再在回答里内联列出；浮层挂在 body 上，position:fixed 不受会话区滚动与裁剪影响。 */

.source-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  transition: all 0.2s;
}

.source-trigger:hover {
  border-color: var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
}

.source-popover {
  position: fixed;
  z-index: 60;
  width: min(470px, calc(100vw - 24px));
  max-height: min(72vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  animation: source-pop-in 0.18s var(--ease-out);
}

.source-popover .sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 8px;
  border-bottom: 1px solid var(--line);
}

.source-popover .sp-title {
  font-size: 10px;
  letter-spacing: var(--tracking-label-wide);
  color: var(--ink-3);
}

.source-popover .sp-close {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
  border-radius: 50%;
  transition: all 0.2s;
}
.source-popover .sp-close:hover {
  background: var(--panel-2);
  color: var(--ink);
}

.source-popover .sp-body {
  overflow-y: auto;
  padding: 0px 12px 8px;
}
.source-popover .source-item {
  padding: 8px 4px;
  border-radius: 4px;
}
.source-popover .source-item.is-target {
  background: var(--accent-soft);
}
.source-popover .source-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@keyframes source-pop-in {
  from {
  opacity: 0;
  transform: translateY(-5px);
}
  to {
  opacity: 1;
  transform: none;
}
}

/* ============================================================
   组件构造基线（《交互体验规范》§4.0）—— 逐族覆盖高度 / 内距 / 圆角。
   面板与浮层不在此列：其 padding 是结构值（给把手让位、撑满滚动区）。
   ============================================================ */
/* 药丸 / chip / 标签 */
.context-chip, .preset-question, .source-chip, .util-badge { border-radius: 999px; padding: 0 12px; min-height: 22px; line-height: 22px; }
/* 按钮（普通） */
.top-button, .toggle-button { border-radius: 4px; padding: 0 12px; min-height: 22px; line-height: 22px; }
/* 按钮（工具条内密集） */
.util-button { border-radius: 4px; padding: 0 8px; min-height: 19px; line-height: 19px; }
/* 输入行 */
.composer-row { border-radius: 4px; padding: 0 8px; min-height: 22px; line-height: 22px; }
/* 复选行 */
.util-check { min-height: 22px; line-height: 22px; }
/* 卡片 */
.candidate-card, .source-item { border-radius: 8px; padding: 16px; }

/* ============================================================
   主题收尾（探索深色）
   ============================================================ */

/* 详情卡投影随主题换色（feDropShadow 的 flood-* 是 CSS 属性，可被 var() 覆盖） */
#card-shadow feDropShadow {
  flood-color: var(--shadow-flood);
  flood-opacity: var(--shadow-flood-opacity);
}

/* SVG 点阵图案随主题换色（index-dual.html defs 里 circle 的颜色由 CSS 接管） */
#dot-grid circle {
  fill: var(--canvas-dot);
}

/* 主题色 0.45s 过渡（有 transform 过渡的浮层把原过渡合并保留） */
body, .network-shell, .image-reader, .source-popover,
.view-switch button {
  transition: background-color 0.45s var(--ease-out), color 0.45s var(--ease-out),
    border-color 0.45s var(--ease-out);
}
.topbar, .left-util, .panel-handle {
  transition: transform 0.32s var(--ease-out), background-color 0.45s var(--ease-out),
    color 0.45s var(--ease-out), border-color 0.45s var(--ease-out);
}

/* ---------- 按压反馈（OQ-23：补 :active 第一批，全部主按钮） ---------- */
.top-button:active, .toggle-button:active, .preset-question:active,
.timeline-eras button:active, .view-switch button:active, .zoom-controls button:active,
.related-object:active, .candidate-actions button:active,
.composer-tool:active {
  transform: translateY(1px);
}

/* ---------- 手机触屏布局：保留桌面双栏，移动端以全屏抽屉切换 AI ---------- */
@media (max-width: 700px) {
  .app {
    height: 100dvh;
    min-height: 100dvh;
  }
  .workspace,
  .workspace.ai-collapsed {
    display: block;
    height: 100%;
  }
  .knowledge-workspace {
    height: 100%;
    border: 0;
  }
  .kw-head {
    align-items: flex-start;
    padding: calc(58px + env(safe-area-inset-top)) 14px 8px;
  }
  .kw-head h2 {
    font-size: 18px;
  }
  .kw-meta {
    padding-top: 2px;
  }
  .kw-meta .legend {
    display: none;
  }
  #graph-count {
    max-width: 150px;
    text-align: right;
    line-height: 1.5;
  }
  .network-shell {
    margin: 0 12px;
  }
  .display-controls {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .toggle-button,
  .canvas-search-toggle {
    min-height: 44px;
    padding: 0 12px;
  }
  .canvas-search-close {
    width: 40px;
    height: 40px;
  }
  .canvas-search.is-open .canvas-search-field {
    width: min(250px, calc(100vw - 48px));
  }
  .canvas-search-results {
    width: min(300px, calc(100vw - 48px));
  }
  .canvas-search-item {
    min-height: 44px;
  }
  .zoom-controls {
    top: auto;
    right: 8px;
    bottom: 42px;
  }
  .zoom-controls button {
    min-width: 44px;
    height: 44px;
  }
  .interaction-hint {
    left: 16px;
    right: 16px;
    bottom: 8px;
    max-width: none;
    font-size: 11px;
    line-height: 1.5;
  }
  .movement-caption {
    min-height: 96px;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 44px 28px;
    text-align: center;
  }
  .movement-caption strong {
    font-size: 21px;
    line-height: 1.35;
  }
  .movement-caption span {
    line-height: 1.5;
  }
  .timeline {
    left: 12px;
    right: 12px;
  }
  .timeline-eras {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .timeline-eras button,
  .view-switch button,
  .top-button,
  .util-button,
  .preset-question {
    min-height: 44px;
  }
  .timeline-readout {
    flex-wrap: wrap;
    gap: 2px 10px;
    white-space: normal;
  }
  .panel-handle {
    z-index: 50;
    width: 44px;
    min-height: 96px;
  }
  .panel-handle.is-right {
    right: 0;
    transform: translate(0, -50%);
  }
  .left-util {
    width: min(300px, calc(100vw - 44px));
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding-top: 20px;
    padding-bottom: 20px;
  }
  .util-check {
    min-height: 44px;
  }
  .ai-workspace {
    position: fixed;
    inset: 0;
    z-index: 45;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
  }
  .workspace.ai-collapsed .ai-workspace {
    display: none;
  }
  .ai-head {
    padding-top: calc(58px + env(safe-area-inset-top));
  }
  .ai-head,
  .preset-row,
  .context-bar,
  .conversation {
    padding-left: 20px;
    padding-right: 64px;
  }
  .composer {
    padding: 12px 64px 12px 20px;
  }
  .composer-row {
    min-height: 48px;
  }
  #send-question {
    min-width: 44px;
    min-height: 44px;
  }
  .reader-panel {
    width: calc(100% - 24px);
    height: calc(100% - 80px);
  }
  .reader-close,
  .reader-step {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ---------- 尊重系统「减少动态效果」（OQ-23 / WCAG 2.2 SC 2.3.3） ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* ---------- 左侧 Chat：独立历史栏 + 对话栏 + 可调分界线 ---------- */
.chat-history-panel {
  flex: 0 0 216px;
  width: 216px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.chat-history-head {
  flex: none;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px 18px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.chat-history-head button,
.chat-history-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color .18s, background-color .18s;
}

.chat-history-head button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.chat-history-head button:hover,
.chat-history-toggle:hover,
.chat-history-toggle[aria-expanded="true"] {
  color: var(--ink);
  background: var(--panel-2);
}

.chat-history-head svg,
.chat-history-toggle svg,
.new-chat-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-history-new {
  flex: none;
  padding: 2px 12px 14px;
}

.new-chat-button {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  transition: border-color .18s, background-color .18s;
}

.new-chat-button:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.chat-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 16px;
  scrollbar-width: thin;
}

.chat-history-item {
  position: relative;
  width: 100%;
  display: block;
  text-align: left;
  border: 0;
  border-radius: 6px;
  margin: 2px 0;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color .16s, background-color .16s;
}

.chat-history-item:hover {
  background: var(--panel-2);
  color: var(--ink);
}

.chat-history-item.is-active {
  background: var(--accent-soft);
  color: var(--ink);
}

.chat-history-item strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-history-item time {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--ink-3);
}

.chat-history-empty {
  margin: 0;
  padding: 22px 10px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
}

.chat-history-toggle {
  flex: none;
  min-height: 34px;
  gap: 7px;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
}

.preset-row {
  padding: 8px 22px;
}

.preset-questions {
  justify-content: flex-start;
}

.context-bar {
  padding: 8px 22px;
  background: color-mix(in srgb, var(--panel) 46%, transparent);
}

.conversation {
  padding: 24px clamp(20px, 3vw, 36px);
  scrollbar-width: thin;
}

.conversation:empty::before {
  content: "从一个设计史问题开始";
  display: block;
  margin: clamp(48px, 12vh, 120px) auto 0;
  max-width: 320px;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1.8;
  text-align: center;
}

.user-message .message-body {
  max-width: 82%;
  border: 0;
  border-radius: 12px 12px 3px 12px;
  padding: 9px 14px;
  background: var(--panel-2);
}

.composer {
  padding: 14px clamp(18px, 3vw, 32px) 16px;
  background: var(--bg);
}

.composer-label {
  margin-bottom: 7px;
}

.composer-row {
  min-height: 48px;
  border-radius: 12px;
  padding: 5px 5px 5px 13px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}

.composer-row:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer-row {
  align-items: flex-end;
}

.composer-input-wrap {
  flex: 1;
  min-width: 0;
}

#question-input {
  display: block;
  width: 100%;
  min-height: 36px;
  max-height: 168px;
  padding: 7px 0 5px;
  overflow-x: hidden;
  overflow-y: auto;
  resize: none;
  line-height: 1.7;
  scrollbar-width: thin;
}

#send-question {
  margin-bottom: 1px;
}

.composer-entity-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 0 2px;
}

.composer-entity-link {
  max-width: 100%;
  border: 0;
  border-bottom: 1px solid var(--accent-line);
  border-radius: 0;
  padding: 1px 0;
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  text-align: left;
}

.composer-entity-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.composer-status {
  min-height: 17px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-divider {
  order: 2;
  position: relative;
  z-index: 20;
  width: 9px;
  margin-left: -1px;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.workspace-divider::before {
  content: "";
  position: absolute;
  inset: 0 3px;
  background: var(--line);
  transition: background-color .18s;
}

.workspace-divider span {
  position: absolute;
  left: 1px;
  top: 50%;
  width: 7px;
  height: 42px;
  border-radius: 4px;
  background: var(--line-strong);
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity .18s, background-color .18s;
}

.workspace-divider:hover span,
.workspace-divider:focus-visible span,
.workspace.is-resizing .workspace-divider span {
  opacity: 1;
  background: var(--accent);
}

.workspace-divider:hover::before,
.workspace.is-resizing .workspace-divider::before {
  background: var(--accent-line);
}

/* 知识网络的筛选入口跟随网络移到最右侧，避免与历史栏争夺左缘。 */
.left-hotzone {
  left: auto;
  right: 0;
}

.left-util {
  left: auto;
  right: 0;
  transform: translate(106%, -50%);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 12px 32px 12px 16px;
}

.panel-handle.is-left {
  left: auto;
  right: 0;
  border-left: 1px solid var(--line);
  border-right: none;
  border-radius: 8px 0 0 8px;
}

.panel-handle.is-right {
  left: 0;
  right: auto;
  transform: translate(-50%, -50%);
}

@media (max-width: 700px) {
  .workspace-divider {
    display: none;
  }
  .ai-workspace {
    border-right: 0;
  }
  .chat-history-panel {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 8;
    width: min(300px, 84vw);
    box-shadow: var(--shadow-float);
  }
  .chat-history-head,
  .new-chat-button,
  .chat-history-item,
  .chat-history-toggle {
    min-height: 44px;
  }
  .ai-head {
    min-height: 102px;
    padding: calc(58px + env(safe-area-inset-top)) 16px 10px 64px;
  }
  .ai-head,
  .preset-row,
  .context-bar,
  .conversation {
    padding-left: 20px;
    padding-right: 20px;
  }
  .ai-head {
    padding-left: 64px;
  }
  .composer {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  }
  .panel-handle.is-right {
    left: 0;
    right: auto;
    transform: translate(0, -50%);
  }
  .conversation:empty::before {
    margin-top: 15vh;
  }
}

/* ---------- 模块缺席降级（内核 DHKernel 按 data-dh-module 标记处理） ----------
   模块文件缺失或被跳过时，内核把归属容器的 hidden 置真并加 html.dh-absent-<id>。
   [hidden] 的 UA 样式优先级低于各组件的 display 规则，这里统一强制。 */
[data-dh-module][hidden] {
  display: none !important;
}

/* AI 对话模块缺席：知识网络独占整行（口径与 .workspace.ai-collapsed 一致） */
html.dh-absent-ai-conversation .workspace {
  grid-template-columns: minmax(0, 1fr);
}
html.dh-absent-ai-conversation .knowledge-workspace {
  border-right: none;
}

/* ============================================================
   视图层：顶栏导航 / 首页 / 占位界面
   设计依据：docs/界面架构与模块方案.md；token 沿用本文件总纲。
   ============================================================ */

/* ---------- 顶栏视图导航 ---------- */
.view-nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.view-nav-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: var(--tracking-label-tight);
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  transition: color .18s var(--ease-out), background-color .18s, border-color .18s;
}
.view-nav-item:hover {
  color: var(--ink);
  background: var(--accent-soft);
}
.view-nav-item.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}


/* ---------- 首页：3D 坐具星丛 ---------- */
.home-sea {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  background: var(--bg);
}
.home-sea canvas { display: block; width: 100%; height: 100%; }
/* 平铺星丛：与 3D 星丛互斥显示；顶部让出问题大字层的高度。 */
.home-flat {
  position: absolute;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  padding: 220px 24px 24px;
  background: var(--bg);
}
.home-flat[hidden] { display: none; }
/* 平铺星丛网格：卡片由 sea-flat 渲染进容器。 */
.home-flat {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  align-content: start;
}
.sea-flat-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s;
}
.sea-flat-card:hover { border-color: var(--accent-line); }
.sea-flat-img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.sea-flat-name {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-2);
  text-align: left;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
/* 悬停椅名标签：跟随鼠标，由 JS 定位 */
.sea-label {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .15s;
  white-space: nowrap;
  z-index: 3;
}
/* 关联理由弹窗：问题模式下跟随被悬停的关联卡片，由 JS 定位 */
.sea-reason {
  position: absolute;
  top: 0;
  left: 0;
  width: 240px;
  pointer-events: none;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-float);
  z-index: 4;
}
.sea-reason[hidden] { display: none; }
.sea-reason-name {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.sea-reason-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
}
@media (prefers-reduced-motion: reduce) {
  .sea-label { transition: none; }
}

/* ---------- 创作视图容器（iframe 内嵌创作页） ---------- */
.create-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #141518;
}
.create-view iframe {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  background: #141518;
}
/* create 视图激活时隐藏父页悬浮件。创作页自带顶栏与阶段导航
   （首页/图谱链接经 hash 驱动外层路由），父页顶栏、顶部热区与
   账号件不再叠在 iframe 上。账号件显示与否由内联样式控制，
   故此处用 !important 覆盖。 */
body:has(.create-view.is-active) .topbar,
body:has(.create-view.is-active) .top-hotzone,
body:has(.create-view.is-active) .auth-ui-widget {
  display: none !important;
}

/* ---------- 首页容器 ---------- */
.home-view {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ---------- 问题大字层 ---------- */
.home-qlayer {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 72px 24px 24px;
  pointer-events: none;   /* 层本身不挡星丛拖拽，交互元素各自打开。 */
  /* 文字背后的暗色晕，保证大字在亮图上可读。 */
  background: radial-gradient(ellipse 62% 46% at 50% 18%, rgba(18, 19, 23, .58), rgba(18, 19, 23, 0) 72%);
}
.home-qlayer > * { pointer-events: auto; }
.home-qlayer > .home-hint,
.home-qlayer > .home-interpretation { pointer-events: none; }
/* 问题行：左右箭头贴在文字两侧，与文字同一垂直中心。 */
.home-qrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin: 0 0 12px;
}
.home-question {
  margin: 0 0 12px;
  max-width: 860px;
  font-size: 40px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: var(--tracking-title2);
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(20, 21, 24, .8);
  cursor: default;
  outline: none;
}
.home-qrow .home-question {
  flex: 0 1 auto;
  max-width: min(70vw, 860px);
  margin: 0;
  text-align: center;
}
.home-question.is-editable {
  cursor: text;
  border-bottom: 1px dashed var(--accent-line);
  padding-bottom: 4px;
}
.home-question.is-editable:focus { border-bottom-style: solid; }
/* 非编辑态的大字不拦截滚轮，缩放事件落到下层星丛。 */
.home-question:not(.is-editable) { pointer-events: none; }
.home-hint {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--ink-2);
  text-shadow: 0 1px 12px rgba(20, 21, 24, .9);
}
.home-hint[hidden] { display: none; }
.home-interpretation {
  margin: 0 auto 14px;
  max-width: 620px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
  text-shadow: 0 1px 12px rgba(20, 21, 24, .9);
}
.home-interpretation[hidden] { display: none; }
.home-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: nowrap;
  max-width: 100%;
  margin-top: 6px;
}
.home-actions[hidden] { display: none; }
/* 三个按钮同一行；空间不足时整体收缩，不换行。 */
.home-actions > button {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
}
.home-enter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  border: 1px solid var(--accent-line);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  letter-spacing: var(--tracking-label-tight);
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease-out), box-shadow .18s, background-color .18s;
}
.home-enter-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .32);
}
.home-enter-btn svg { width: 16px; height: 16px; }
.home-enter-btn[hidden] { display: none; }
.home-own-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  letter-spacing: var(--tracking-label-tight);
  padding: 11px 22px;
  border-radius: 999px;
  transition: transform .18s var(--ease-out), background-color .18s, color .18s;
}
.home-own-btn:hover {
  transform: translateY(-1px);
  background: var(--accent);
  color: var(--on-accent);
}
.home-own-btn[hidden] { display: none; }
/* 星丛模式切换：次级描边小按钮，文字由 JS 在「平铺星丛」「立体星丛」之间切换。 */
.home-mode-btn,
.home-edit-btn2 {
  display: inline-flex;
  align-items: center;
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: var(--tracking-label-tight);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .18s var(--ease-out), background-color .18s, color .18s, border-color .18s;
}
.home-mode-btn:hover,
.home-edit-btn2:hover {
  transform: translateY(-1px);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.home-mode-btn[hidden],
.home-edit-btn2[hidden] { display: none; }

/* ---------- 自建问题编辑面板 ---------- */
.home-edit {
  margin-top: 18px;
  width: min(560px, calc(100vw - 48px));
  max-height: 32vh;
  overflow-y: auto;
  text-align: left;
  background: rgba(28, 29, 33, .78);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, .4);
}
.home-edit[hidden] { display: none; }
.home-edit-title {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: var(--tracking-label);
  color: var(--ink-3);
}
.home-edit-empty {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.home-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.home-edit-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  flex: none;
}
.home-edit-body { flex: 1 1 auto; min-width: 0; }
.home-edit-name {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.home-edit-reason {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  padding: 5px 8px;
}
.home-edit-reason:focus { outline: none; border-color: var(--accent-line); }
.home-edit-remove {
  flex: none;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.home-edit-remove:hover { color: #c0392b; border-color: #c0392b; }
.home-edit-row2 {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.home-edit-btn {
  appearance: none;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color .18s, color .18s;
}
.home-edit-btn:hover { background: var(--accent); color: var(--on-accent); }
.home-edit-btn.is-danger {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-3);
}
.home-edit-btn.is-danger:hover { color: #c0392b; border-color: #c0392b; background: transparent; }

/* ---------- 问题切换箭头（位于问题文字两侧） ---------- */
.home-nav-arrow {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: color .18s, border-color .18s, background-color .18s;
}
.home-nav-arrow:hover {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}
.home-nav-arrow svg { width: 18px; height: 18px; }

/* ---------- 首页节点详情浮窗 ---------- */
.home-popover {
  position: fixed;
  z-index: 60;
  width: min(420px, calc(100vw - 40px));
  padding: 18px 18px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: var(--shadow-float);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.home-popover[hidden] { display: none; }
.home-popover-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.home-popover-close:hover { color: var(--ink); background: var(--accent-soft); }
.home-popover-close svg { width: 16px; height: 16px; }
.home-popover-title {
  margin: 0 30px 4px 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: var(--tracking-title3);
  color: var(--ink);
}
.home-popover-meta {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  color: var(--accent);
}
.home-popover-text {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
}
.home-popover-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.home-popover-thumbs:empty { display: none; }
/* 浮窗内大图：点开缩略图后在浮窗里展开这张图片本身。 */
.home-popover-hero {
  margin-bottom: 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: zoom-out;
}
.home-popover-hero[hidden] { display: none; }
.home-popover-hero img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: var(--bg);
}
.home-popover-thumb {
  appearance: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .18s;
}
.home-popover-thumb:hover { border-color: var(--accent-line); }
.home-popover-thumb img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
}
/* 缩略图右下角的圆形「+」：与星丛节点圆圈角上的加号同形，
   点击把该坐具加入当前自建问题，已加入时变为对勾。 */
.home-popover-thumbslot {
  position: relative;
  display: flex;
}
.home-popover-add {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(28, 29, 33, .92);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
  transition: color .18s, border-color .18s, background-color .18s;
}
.home-popover-add:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}
.home-popover-add.is-added {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.home-popover-add .icon { width: 12px; height: 12px; }
.home-popover-link {
  appearance: none;
  width: 100%;
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color .18s, color .18s;
}
.home-popover-link:hover {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- 首页轻提示（教师议题只读等） ---------- */
.home-toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 90;
  transform: translate(-50%, 8px);
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  font-size: 12.5px;
  letter-spacing: .01em;
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.home-toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 添加坐具选择器 ---------- */
.home-picker {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(16, 17, 20, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-picker[hidden] { display: none; }
.home-picker-panel {
  width: min(680px, calc(100vw - 48px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.home-picker-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.home-picker-search {
  flex: 1 1 auto;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  padding: 8px 12px;
}
.home-picker-search:focus { outline: none; border-color: var(--accent-line); }
.home-picker-close {
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.home-picker-close:hover { color: var(--ink); background: var(--accent-soft); }
.home-picker-close svg { width: 16px; height: 16px; }
.home-picker-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
  padding: 14px;
}
.home-picker-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s;
}
.home-picker-card:hover { border-color: var(--accent-line); }
.home-picker-card img {
  width: 100%;
  height: 84px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.home-picker-card span {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--ink-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---------- 视图层响应式 ---------- */
@media (max-width: 720px) {
  .home-qlayer { padding: 56px 16px 20px; }
  .home-qrow { gap: 10px; margin-bottom: 10px; }
  .home-qrow .home-question { max-width: 72vw; }
  .home-question { font-size: 26px; }
  .home-nav-arrow { width: 32px; height: 32px; }
  .home-nav-arrow svg { width: 16px; height: 16px; }
  .home-interpretation { font-size: 12.5px; }
  .view-nav-item { padding: 6px 9px; font-size: 11px; }
  .home-actions { gap: 8px; }
  .home-enter-btn, .home-own-btn { padding: 9px 13px; font-size: 12px; }
  .home-mode-btn,
.home-edit-btn2 { padding: 8px 12px; font-size: 11.5px; }
  .home-flat { padding: 200px 16px 20px; }
  .sea-reason { width: 200px; }
}
@media (max-width: 420px) {
  .home-enter-btn, .home-own-btn { padding: 8px 10px; font-size: 11px; letter-spacing: 0; }
  .home-mode-btn,
.home-edit-btn2 { padding: 7px 10px; font-size: 11px; }
  .home-flat { padding-top: 240px; }
}
@media (max-width: 360px) {
  .home-qlayer { padding-left: 12px; padding-right: 12px; }
  .home-actions { gap: 6px; }
  .home-enter-btn, .home-own-btn { padding: 8px 8px; font-size: 10.5px; }
  .home-enter-btn svg { display: none; }
  .home-mode-btn,
.home-edit-btn2 { padding: 7px 8px; font-size: 10.5px; }
}


/* ============================================================
   数据视图（我的数据：问答记录 / 行为流水 / 生成图 / 画布存档）
   深色主题与首页、创作视图一致：面板抬升面 + 细线分隔。
   内容由 records-view 模块渲染；模块缺席时隐藏导航项。
   ============================================================ */

.records-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
}

/* 模块缺席（文件被删）：视图容器为空，导航项一并隐藏，避免进入空白页。 */
html.dh-absent-records-view [data-nav-view="records"] {
  display: none;
}

.records-panel {
  max-width: 1080px;
  margin: 0 auto;
  padding: 92px 28px 56px;
}

/* ---------- 头部 ---------- */
.records-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.records-eyebrow {
  margin: 0 0 4px;
  font-size: 10px;
  letter-spacing: var(--tracking-label-wide);
  color: var(--ink-3);
}
.records-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: var(--tracking-large-title);
  color: var(--ink);
}
.records-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
}
.records-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.records-status {
  font-size: 11.5px;
  color: var(--ink-3);
}
.records-refresh {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  transition: border-color .18s, color .18s;
}
.records-refresh:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

/* ---------- 页签 ---------- */
.records-tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.records-tab {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  letter-spacing: var(--tracking-label-tight);
  color: var(--ink-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px 10px;
  white-space: nowrap;
  transition: color .18s, border-color .18s;
}
.records-tab:hover {
  color: var(--ink);
}
.records-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.records-flash {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--accent);
}
.records-flash.is-error {
  color: #d98b7c;
}

/* ---------- 列表 ---------- */
.records-body {
  padding-top: 18px;
}
.records-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.records-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.records-row.is-open {
  border-color: var(--line-strong);
}
.records-row-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 13px 16px;
}
button.records-row-main {
  cursor: pointer;
  transition: background-color .18s;
}
button.records-row-main:hover {
  background: var(--accent-soft);
}
.records-row-main.is-static {
  cursor: default;
}
.records-row-title {
  font-size: 13.5px;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.records-row-meta {
  flex: 0 0 auto;
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.records-row-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 13px;
}
.records-action {
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  transition: border-color .18s, color .18s, background-color .18s;
}
.records-action:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}
.records-action.is-danger:hover {
  border-color: rgba(217, 139, 124, .6);
  color: #d98b7c;
}
.records-retry {
  margin-top: 10px;
}
.records-more {
  margin-top: 10px;
}

/* ---------- 问答消息 ---------- */
.records-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 16px 16px;
  border-top: 1px solid var(--line);
  margin-top: 0;
}
.records-messages.is-note {
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 14px;
}
.records-msg {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 4px 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-2);
}
.records-msg.is-user {
  border-left: 2px solid var(--accent-line);
}
.records-msg.is-assistant {
  border-left: 2px solid var(--personal);
}
.records-msg-role {
  grid-row: 1 / span 2;
  font-size: 11px;
  letter-spacing: var(--tracking-label-tight);
  color: var(--ink-3);
}
.records-msg-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.records-msg-time {
  font-size: 10.5px;
  color: var(--ink-3);
}

/* ---------- 行为流水 ---------- */
.records-events {
  list-style: none;
  margin: 0;
  padding: 6px 16px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.records-events.is-note {
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 14px;
}
.records-event {
  display: grid;
  grid-template-columns: 72px 96px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}
.records-event:last-child {
  border-bottom: none;
}
.records-event-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.records-event-type {
  font-size: 11.5px;
  color: var(--accent);
  white-space: nowrap;
}
.records-event-label {
  font-size: 12px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 生成图 ---------- */
.records-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.records-shot {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.records-shot-link {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--panel-2);
}
.records-shot-link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.records-shot figcaption {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px 11px;
}
.records-shot-prompt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.records-shot-meta {
  font-size: 10.5px;
  color: var(--ink-3);
}

/* ---------- 空态 / 加载 / 降级 ---------- */
.records-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 34px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--panel);
}
.records-empty strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.records-empty span {
  font-size: 12.5px;
  color: var(--ink-2);
}
.records-empty.is-loading span {
  color: var(--ink-3);
}

@media (max-width: 720px) {
  .records-panel { padding: 84px 16px 40px; }
  .records-title { font-size: 21px; }
  .records-head { align-items: flex-start; }
  .records-event { grid-template-columns: 64px 84px minmax(0, 1fr); gap: 8px; }
  .records-row-main { flex-direction: column; gap: 3px; }
  .records-row-meta { white-space: normal; }
}
