/* styles/loading.css · 加载反馈 + 左侧导航分组
 *
 * 两块内容:
 *   1. 加载反馈 —— 首屏遮罩 .app-boot / 顶部进度条 #appProgress / 会话骨架屏 .chat-skel
 *   2. 导航分组 —— 小标题 .nav-group-title + (i) 按钮 + 介绍弹框 .ngi-*
 *
 * 配色一律走已有 token (--paper / --ink / --accent / --line …), 四套主题
 * (sky / origin / dark / dark2) 自动跟随, 不新增颜色常量。
 * 侧栏内的样式挂在 .sidebar 作用域下 —— 那里有一套局部 token 覆盖。
 */

/* ═══════════════════════════════════════════════════════════════════
   1. 首屏加载遮罩
   ═══════════════════════════════════════════════════════════════════ */
.app-boot {
  position: fixed;
  inset: 0;
  z-index: 100000;                 /* 站内最高的是 9999, 这里必须盖住它 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg, #f0f6fc);
  transition: opacity .38s ease, visibility .38s ease;
}
.app-boot.is-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.app-boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  /* 遮罩自己带一点入场 —— 硬切上去会显得生硬 */
  animation: appBootIn .5s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes appBootIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.app-boot-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  animation: appBootPulse 2.2s ease-in-out infinite;
}
@keyframes appBootPulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: .62; transform: scale(.955); }
}

.app-boot-name {
  font-family: var(--display, "Cormorant Garamond", serif);
  font-size: 25px;
  letter-spacing: .06em;
  color: var(--ink, #0d2540);
}
.app-boot-name em { font-style: normal; color: var(--vermilion, #2f7fd8); }

/* 进度条本体 —— 不知道要多久, 所以走"来回扫"而不是百分比 */
.app-boot-bar {
  width: 168px;
  height: 2px;
  border-radius: 2px;
  background: var(--rule-soft, #e5eef7);
  overflow: hidden;
  margin-top: 2px;
}
.app-boot-bar > i {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--vermilion, #2f7fd8);
  animation: appBootSweep 1.15s cubic-bezier(.45,.05,.35,1) infinite;
}
@keyframes appBootSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.app-boot-status {
  font-size: 12.5px;
  color: var(--ink-mute, #6b7d9a);
  letter-spacing: .02em;
  min-height: 1em;                 /* 文案换行时不要抖 */
}

/* ═══════════════════════════════════════════════════════════════════
   2. 顶部轻量进度条
   ═══════════════════════════════════════════════════════════════════
   给"有等待、但不该遮全屏"的动作用: 打开会话、切项目、重连…… */
.app-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 99990;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.app-progress.is-on { opacity: 1; }
.app-progress > i {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg,
      transparent,
      var(--vermilion, #2f7fd8) 42%,
      var(--vermilion, #2f7fd8) 58%,
      transparent);
  animation: appProgSweep 1.05s cubic-bezier(.45,.05,.35,1) infinite;
}
/* 收尾: 铺满再淡出, 表示"跑完了"而不是"断了" */
.app-progress.is-done > i {
  animation: none;
  width: 100%;
  background: var(--vermilion, #2f7fd8);
  transition: width .18s ease;
}
@keyframes appProgSweep {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(430%); }
}

/* ═══════════════════════════════════════════════════════════════════
   3. 会话骨架屏 —— 点历史会话后立刻铺在对话区
   ═══════════════════════════════════════════════════════════════════ */
.chat-skel {
  padding: 20px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: chatSkelIn .18s ease both;
}
@keyframes chatSkelIn { from { opacity: 0; } to { opacity: 1; } }

.chat-skel .cs-row { display: flex; gap: 10px; }
.chat-skel .cs-row.is-user { justify-content: flex-end; }

.chat-skel .cs-bubble {
  max-width: 68%;
  min-width: 168px;
  padding: 12px 14px;
  border-radius: 12px 12px 3px 12px;
  background: var(--paper-warm, #f5f9ff);
  border: 1px solid var(--rule-soft, #e5eef7);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-skel .cs-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--rule-soft, #e5eef7);
}
.chat-skel .cs-block {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 3px;
}
.chat-skel .cs-card {
  margin-top: 4px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--rule-soft, #e5eef7);
  background: var(--paper-warm, #f5f9ff);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 骨架条 —— 微光扫过, 表示"在加载"而不是"坏了" */
.chat-skel .cs-bar {
  height: 9px;
  border-radius: 4px;
  background: linear-gradient(90deg,
      var(--rule-soft, #e5eef7) 25%,
      var(--rule, #d0dee9) 37%,
      var(--rule-soft, #e5eef7) 50%);
  background-size: 400% 100%;
  animation: csShimmer 1.5s ease-in-out infinite;
}
.chat-skel .cs-bar.strong { height: 12px; }
.chat-skel .cs-bar.w30 { width: 30%; }
.chat-skel .cs-bar.w35 { width: 35%; }
.chat-skel .cs-bar.w40 { width: 40%; }
.chat-skel .cs-bar.w45 { width: 45%; }
.chat-skel .cs-bar.w55 { width: 55%; }
.chat-skel .cs-bar.w60 { width: 60%; }
.chat-skel .cs-bar.w70 { width: 70%; }
.chat-skel .cs-bar.w72 { width: 72%; }
.chat-skel .cs-bar.w78 { width: 78%; }
.chat-skel .cs-bar.w85 { width: 85%; }
.chat-skel .cs-bar.w88 { width: 88%; }
.chat-skel .cs-bar.w90 { width: 90%; }
.chat-skel .cs-bar.w92 { width: 92%; }
@keyframes csShimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 底部一行说明 —— 骨架能表达"在加载", 但说清"在载入会话"更让人安心 */
.chat-skel .cs-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--ink-mute, #6b7d9a);
}
.chat-skel .cs-spin {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.6px solid var(--rule, #d0dee9);
  border-top-color: var(--vermilion, #2f7fd8);
  animation: csSpin .75s linear infinite;
}
@keyframes csSpin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════
   3b. 库页骨架屏上的状态说明
   ═══════════════════════════════════════════════════════════════════
   技能库 catalog 拉不到时要退避重试 ~15s。骨架自己只会闪, 说不清"还在重试",
   这行字负责把等待解释掉。 */
.view-skel > .sk-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 9px 13px;
  border: 1px solid var(--rule-soft, #e5eef7);
  border-radius: 7px;
  background: var(--paper-warm, #f5f9ff);
  color: var(--ink-mute, #6b7d9a);
  font-size: 12.5px;
  line-height: 1.6;
}
.view-skel > .sk-note .sk-note-spin {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--rule, #d0dee9);
  border-top-color: var(--vermilion, #2f7fd8);
  animation: csSpin .75s linear infinite;
}

/* ═══════════════════════════════════════════════════════════════════
   4. "点了立刻有反应" —— 侧栏会话项 / 工作台卡片的忙碌态
   ═══════════════════════════════════════════════════════════════════ */
.sidebar .qsl-hist.is-busy,
.qsl-scard.is-busy {
  position: relative;
  opacity: .72;
}
.sidebar .qsl-hist.is-busy { background: rgba(0,0,0,.05); }

/* 右侧一个小转圈 —— 让"我点的是这一条"一目了然 */
.sidebar .qsl-hist.is-busy::after,
.qsl-scard.is-busy::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--accent, #2f7fd8);
  border-right-color: var(--accent, #2f7fd8);
  animation: csSpin .7s linear infinite;
}
.qsl-scard.is-busy::after { right: 12px; top: 14px; margin-top: 0; }

/* ═══════════════════════════════════════════════════════════════════
   5. 左侧导航 · 分组小标题
   ═══════════════════════════════════════════════════════════════════
   .nav-item 之上的一行类别名 + 一个 (i) 介绍按钮。
   视觉上要明显"轻于"导航项本身 —— 它是标签, 不是可跳转的入口。 */
.sidebar .nav-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 4px;
  color: var(--muted, #6b7d9a);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  user-select: none;
}
/* 第一组紧跟在 divider 后面, 上间距收一点免得空一大块 */
.sidebar .nav-divider + .nav-group-title { padding-top: 4px; }

.sidebar .nav-group-title > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* (i) 按钮 —— 比标题淡一档, 但不能淡到看不见:
   浅色主题下 --muted-2 配侧栏底色只有 1.76:1, 属于"知道它在那儿才找得到"。
   改用 --muted (和标题同色) 再靠 opacity 拉开层次, 实测 ~2.9:1, 可辨认。 */
.nav-group-info {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted, #6b7d9a);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .8;
  transition: color .15s, opacity .15s, background .15s, transform .15s;
}
.nav-group-info svg { width: 13px; height: 13px; }
.nav-group-info:hover {
  color: var(--accent, #2f7fd8);
  opacity: 1;
  background: var(--accent-bg, rgba(47,127,216,.10));
  transform: scale(1.12);
}
.nav-group-info:focus-visible {
  outline: 2px solid var(--accent, #2f7fd8);
  outline-offset: 1px;
}

/* 收起侧栏时: 文字没了, 只留一条极窄的分隔感 —— 但按钮要留着可点 */
body.sidebar-collapsed .sidebar .nav-group-title {
  justify-content: center;
  padding: 8px 0 3px;
}
body.sidebar-collapsed .sidebar .nav-group-title > span { display: none; }

/* ═══════════════════════════════════════════════════════════════════
   6. 分组介绍弹框
   ═══════════════════════════════════════════════════════════════════ */
.ngi-mask {
  position: fixed;
  inset: 0;
  z-index: 99995;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 22, 40, .38);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .2s ease;
}
.ngi-mask.is-open { opacity: 1; }
.ngi-mask[hidden] { display: none; }

.ngi-modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(76vh, 720px);
  overflow-y: auto;
  background: var(--paper, #fff);
  border: 1px solid var(--rule, #d0dee9);
  border-radius: 12px;
  box-shadow: 0 24px 60px -12px rgba(10, 22, 40, .28);
  padding: 26px 28px 24px;
  transform: translateY(10px) scale(.985);
  transition: transform .22s cubic-bezier(.2,.7,.3,1);
  scrollbar-width: thin;
}
.ngi-mask.is-open .ngi-modal { transform: none; }
.ngi-modal::-webkit-scrollbar { width: 6px; }
.ngi-modal::-webkit-scrollbar-thumb {
  background: var(--rule, #d0dee9);
  border-radius: 6px;
}

.ngi-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-mute, #6b7d9a);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.ngi-close svg { width: 15px; height: 15px; }
.ngi-close:hover {
  background: var(--paper-cool, #eaf1fa);
  color: var(--ink, #0d2540);
}

.ngi-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding-right: 30px;             /* 给关闭按钮让位 */
  margin-bottom: 15px;
}
.ngi-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: var(--vermilion-bg, #eaf3fc);
  color: var(--vermilion, #2f7fd8);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ngi-icon svg { width: 21px; height: 21px; }

.ngi-eyebrow {
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: var(--ink-faint, #a0b0c8);
  margin-bottom: 3px;
}
.ngi-title {
  margin: 0;
  font-family: var(--serif, "Noto Serif SC", serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink, #0d2540);
  letter-spacing: .02em;
}

.ngi-body { font-size: 13.5px; line-height: 1.78; color: var(--ink-soft, #38547a); }

.ngi-summary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 2.5px solid var(--vermilion, #2f7fd8);
  background: var(--paper-warm, #f5f9ff);
  color: var(--ink, #0d2540);
  font-size: 13.5px;
  line-height: 1.75;
}

/* 本组包含哪几个入口 —— 可点, 直接跳过去 */
.ngi-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.ngi-entry {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 13px;
  border: 1px solid var(--rule, #d0dee9);
  border-radius: 8px;
  background: var(--paper, #fff);
  cursor: pointer;
  font: inherit;
  transition: border-color .15s, background .15s, transform .15s;
}
.ngi-entry:hover {
  border-color: var(--vermilion-soft, #6ea9e8);
  background: var(--vermilion-bg, #eaf3fc);
  transform: translateX(2px);
}
.ngi-entry-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink, #0d2540);
}
.ngi-entry-arrow {
  width: 13px;
  height: 13px;
  color: var(--ink-faint, #a0b0c8);
  transition: transform .15s, color .15s;
}
.ngi-entry:hover .ngi-entry-arrow {
  color: var(--vermilion, #2f7fd8);
  transform: translateX(2px);
}
.ngi-entry-desc {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-mute, #6b7d9a);
}

.ngi-sec { margin-top: 16px; }
.ngi-sec-title {
  margin: 0 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink, #0d2540);
  letter-spacing: .04em;
  padding-left: 9px;
  border-left: 2px solid var(--rule, #d0dee9);
}
.ngi-sec-body p { margin: 0 0 8px; }
.ngi-sec-body p:last-child { margin-bottom: 0; }

/* 介绍正文：编号流程和定义列表，沿用平台主题色。 */
.ngi-steps { margin: 0; padding: 0; list-style: none; counter-reset: ngi-step; }
.ngi-steps li {
  position: relative;
  padding: 0 0 13px 32px;
  counter-increment: ngi-step;
}
.ngi-steps li:last-child { padding-bottom: 0; }
.ngi-steps li::before {
  content: counter(ngi-step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  color: var(--vermilion, #2f7fd8);
  font-family: var(--mono, monospace);
  font-size: 11px;
  font-weight: 600;
}
.ngi-steps strong { display: block; color: var(--ink, #0d2540); font-weight: 600; }
.ngi-steps span { display: block; }
.ngi-facts { margin: 0; }
.ngi-facts > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 12px; padding: 8px 0; }
.ngi-facts > div + div { border-top: 1px solid var(--rule, #d0dee9); }
.ngi-facts dt { font-weight: 600; color: var(--ink, #0d2540); }
.ngi-facts dd { margin: 0; }
.ngi-mask--modes .ngi-modal { width: min(760px, 100%); }
.ngi-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.ngi-mode + .ngi-mode { border-left: 1px solid var(--rule, #d0dee9); padding-left: 24px; }
.ngi-mode h5 { margin: 2px 0 3px; font-size: 16px; color: var(--ink, #0d2540); }
.ngi-mode .ngi-mode-lead { margin-bottom: 16px; font-size: 12px; color: var(--ink-mute, #6b7d9a); }
.ngi-mode .ngi-mode-goal { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule, #d0dee9); }
.ngi-mode-goal strong { margin-right: 6px; color: var(--vermilion, #2f7fd8); }
#composerToolbar .reasoning-mode-info { width: 24px; height: 28px; border-radius: 5px; }
#composerToolbar .reasoning-mode-info svg { width: 15px; height: 15px; }

/* 图文摘要：自然高度、同屏阅读，框架图保持原始比例。 */
.ngi-mask--hasimg .ngi-modal {
  width: min(1360px, 100%);
  max-height: 90vh;
  padding: 26px 30px 24px;
}
.ngi-mask--hasimg .ngi-head { margin-bottom: 20px; }
.ngi-cols {
  display: grid;
  grid-template-columns: minmax(300px, .9fr) minmax(0, 1.7fr);
  gap: 32px;
  align-items: center;
}
.ngi-col-text { min-width: 0; }
.ngi-mask--hasimg .ngi-summary {
  padding: 0 0 16px;
  margin: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--rule, #d0dee9);
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.85;
  font-weight: 500;
}
.ngi-mask--hasimg .ngi-sec { margin-top: 16px; }
.ngi-mask--hasimg .ngi-sec-title {
  padding: 0;
  border: 0;
  margin-bottom: 5px;
  font-size: 14px;
  letter-spacing: 0;
}
.ngi-mask--hasimg .ngi-sec-body { font-size: 13.5px; line-height: 1.85; }
.ngi-figure { margin: 0; min-width: 0; }
.ngi-figure-link {
  display: block;
  cursor: zoom-in;
  border-radius: 8px;
  background: transparent;
}
.ngi-figure-link:focus-visible { outline: 2px solid var(--accent, #2f7fd8); outline-offset: 4px; }
.ngi-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(90vh - 150px);
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
}
.ngi-figure figcaption {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--rule, #d0dee9);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-mute, #6b7d9a);
}
.ngi-figure-hint { flex-shrink: 0; color: var(--accent, #2f7fd8); }
.ngi-related { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 18px; }
.ngi-related .ngi-entry {
  width: auto;
  display: inline-block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent, #2f7fd8);
  font-size: 12.5px;
}
.ngi-related .ngi-entry:hover { transform: none; text-decoration: underline; }
@media (max-width: 1000px) {
  .ngi-cols { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .ngi-figure img { max-height: none; }
  .ngi-mask--hasimg .ngi-modal { padding: 22px; }
}
@media (max-width: 640px) {
  .ngi-mode-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .ngi-mode + .ngi-mode { padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--rule, #d0dee9); }
}

/* 深色主题下遮罩再压暗一点 —— 浅色遮罩盖在深色页面上会发灰 */
:root[data-theme="dark"] .ngi-mask,
:root[data-theme="dark2"] .ngi-mask {
  background: rgba(0, 0, 0, .55);
}

/* ── 窄屏 ── */
@media (max-width: 640px) {
  .ngi-modal { padding: 22px 18px 20px; max-height: 84vh; }
  .ngi-title { font-size: 17px; }
}

/* ── 尊重"减少动态效果"偏好 ── */
@media (prefers-reduced-motion: reduce) {
  .app-boot-logo,
  .app-boot-bar > i,
  .app-progress > i,
  .chat-skel .cs-bar,
  .chat-skel .cs-spin,
  .sidebar .qsl-hist.is-busy::after,
  .qsl-scard.is-busy::after {
    animation: none;
  }
  .chat-skel .cs-bar { background: var(--rule-soft, #e5eef7); }
  .app-boot-bar > i { width: 100%; }
}
