/* 分析笔记的共用件(/finance/analysis/card.js 与 panel.js 渲染):分析页的信息流与全文页、个股页的「分析」tab、全景页的分析卡共用这一份。
   页面按结构画,不按内容的词画;写入方的字原样放进去。这里有四样:
   - 行情小件 .an-q(现价 涨跌幅)与信号圆点 .an-dots:分析页的报告卡、全景分析卡的主题行、报告的完整格式都用;
   - 一份报告 .an-rep(展开的完整格式,主题面板里的第一条与全文视图同一个画法):
     头行(左:[名称 代码] 时段 写入时间;右:现价 涨跌幅 [操作钮])→ 指令(大号粗体,全页只有它)→ 摘要 → 价位 → 信号 → 步骤 → 关键数字 → [整行「查看全文 ›」];
     头行、指令、摘要一段,下面每段一个灰色小标题,段内行间不画分隔线;哪段没有内容就整段不画;
   - 价位条 .an-lv;
   - 主题面板 .an-panel(panel.js):小标题行(「报告」在左、「记忆 ›」在右)→ 第一条展开 → 往期(.an-row,每条两行:指令;时段名 · 相对时间)→「更多」;
     以及主题弹窗 #mem-dlg(统一壳 dialog.dlg:记忆列表 / 启用开关 / 删除主题)。
   信号与步骤一律墨色(--ink),用实心 / 半心 / 空心、描边粗细、斜线、灰来区分,不用红绿(A 股红涨绿跌,会和涨跌色撞车)。
   涨跌幅照全站红涨绿跌(--up / --down):那是行情,不是写入方的内容。 */

/* 行情小件:现价 涨跌幅(等宽数字);只要涨跌幅的地方不画现价。 */
.an-q { display: inline-flex; align-items: baseline; gap: 8px; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-q .px { color: var(--ink); }
.an-q .up { color: var(--up); }
.an-q .down { color: var(--down); }

/* 信号圆点:每条信号一枚,green / yellow / red 依次实心 / 半心 / 空心,认不出的状态画虚线圈;悬停看「label · state_label · evidence · as_of」。 */
.an-dots { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* 信号标签:圆点 + 名字,一排放不下换行。 */
.an-chips { display: flex; flex-wrap: wrap; gap: 6px 14px; min-width: 0; }
.an-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; line-height: 1.4; color: var(--sec); }
.an-chip .an-dot { width: 9px; height: 9px; }
.an-dot { flex: none; box-sizing: border-box; width: 11px; height: 11px; border: 1.5px solid var(--ink); border-radius: 50%; background: transparent; }
.an-dot.s-green { background: var(--ink); }
.an-dot.s-yellow { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); }
.an-dot.s-other { border-style: dashed; }

/* 步骤圆圈:按 mark 画(waiting 空心 / triggered 描边加粗 / entered 实心 / failed 斜线 / locked 灰)。 */
.an-c { flex: none; box-sizing: border-box; width: 11px; height: 11px; border: 1.5px solid var(--ink); border-radius: 50%; background: transparent; }
.an-c.m-triggered { border-width: 3px; }
.an-c.m-entered { background: var(--ink); }
.an-c.m-failed { background: linear-gradient(135deg, transparent calc(50% - .8px), var(--ink) calc(50% - .8px), var(--ink) calc(50% + .8px), transparent calc(50% + .8px)); }
.an-c.m-locked { border-color: var(--sec); background: var(--fill); opacity: .55; }

.an-none { font-size: 13px; color: var(--sec); }

/* 卡内左右内边距:报告各段、主题面板的行共用,窄屏收到 18px(嵌在别的卡里的可以自己改这个变量)。 */
:root { --an-px: 22px; }
@media (max-width: 680px) { :root { --an-px: 18px; } }

/* ---------- 一份报告 ---------- */
/* 尺寸容器:信号 / 步骤 / 关键数字的列数跟自己的宽度走,不跟视口走。 */
.an-rep { container-type: inline-size; min-width: 0; }
.an-top { border-bottom: 1px solid var(--hair); }
.an-top:last-child { border-bottom: 0; }

/* 头行:左「[名称 代码] 时段 写入时间」,右「现价 涨跌幅 [操作钮]」;放不下时右组折到下一行、仍靠右。 */
.an-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 16px var(--an-px) 4px; font-size: 12.5px; color: var(--sec); }
.an-head .who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.an-head .nm { min-width: 0; font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.an-head a.nm:hover { opacity: .7; }
.an-head a.nm:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.an-head .cd { font: 12px var(--mono); }
.an-head .tm { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-head .act { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.an-head .an-q { gap: 10px; }
.an-head .an-q .px { font-size: 14px; }

/* 指令 / 摘要。 */
.an-first { display: flex; flex-direction: column; gap: 10px; padding: 6px var(--an-px) 20px; }
.an-ins { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.an-sum { margin: 0; font-size: 14.5px; line-height: 1.7; white-space: pre-line; overflow-wrap: anywhere; }

/* 分段:灰色小标题 + 内容。 */
.an-sec { padding-bottom: 4px; }
.an-sub { margin: 0; padding: 12px var(--an-px) 6px; font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--sec); letter-spacing: .02em; }

/* 价位条:刻度范围 = 全部价位与现价的最小 / 最大值各外扩 5%(区间宽度的 5%);价位画竖线、上方标 label 与价格(挤不下自动叠到上一行),
   note 放悬停;现价画圆点。没有价位时整段不画。--rows 由 card.js 量完标签宽度后写。 */
.an-lv { --rows: 1; position: relative; overflow-x: clip; height: calc(var(--rows) * 18px + 20px); margin: 2px var(--an-px) 12px; }
.an-lv .trk { position: absolute; left: 0; right: 0; top: calc(var(--rows) * 18px + 9px); height: 2px; border-radius: 1px; background: var(--hair); }
.an-lv .tk { position: absolute; top: calc(var(--rows) * 18px + 5px); width: 1px; height: 10px; background: var(--ink); opacity: .45; }
.an-lv .now { position: absolute; top: calc(var(--rows) * 18px + 5px); width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--menu); }
.an-lv .lab { position: absolute; top: calc((var(--rows) - 1 - var(--r, 0)) * 18px); left: 0; font-size: 12px; line-height: 16px; color: var(--sec); white-space: nowrap; }
.an-lv .lab b { margin-left: 3px; font: 500 12px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }

/* 信号行(圆点 | label · state_label | evidence | as_of)与步骤行(圆圈 | label · status | text):同一套列,名称不加粗、说明灰字,行间不画线。 */
.an-li { margin: 0; padding: 0 var(--an-px) 8px; list-style: none; }
.an-li li { display: grid; grid-template-columns: 16px 150px minmax(0, 1fr) max-content; column-gap: 12px; align-items: baseline; padding: 5px 0; font-size: 13px; line-height: 1.5; }
.an-li li > :first-child { align-self: start; margin-top: 4.25px; } /* 圆点对第一行文字的中线:(19.5 − 11) / 2 */
.an-li .lb { min-width: 0; overflow-wrap: anywhere; }
.an-li .lb small { margin-left: 6px; font-size: 12px; color: var(--sec); }
.an-li .tx { min-width: 0; color: var(--sec); overflow-wrap: anywhere; }
.an-li .dt { font: 12px var(--mono); font-variant-numeric: tabular-nums; color: var(--sec); white-space: nowrap; }

/* 关键数字:三列表(k | v | ref),每行 subgrid 共享列轨。 */
.an-snap { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, max-content) minmax(0, 1fr); column-gap: 20px; padding: 4px var(--an-px) 10px; font-size: 13px; line-height: 1.5; }
.an-snap > div { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: baseline; padding: 5px 0; }
.an-snap .k, .an-snap .r { color: var(--sec); overflow-wrap: anywhere; }
.an-snap .v { font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@supports not (grid-template-columns: subgrid) {
  .an-snap > div { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; }
}

/* 整行操作(报告最下面的「查看全文 ›」、往期末尾的「更多」):灰字居中。
   「查看全文 ›」是这份报告的收尾,上面不画线(画了像单独一行);「更多」接在往期列表后面,上面一条发丝线。 */
.an-full, .an-more { display: block; width: 100%; padding: 12px var(--an-px); border: 0; background: transparent; color: var(--sec); font: inherit; font-size: 13px; line-height: 1.5; text-align: center; text-decoration: none; cursor: pointer; }
.an-full { padding-top: 4px; }
.an-more { border-top: 1px solid var(--hair); }
.an-top:has(+ .an-full) { border-bottom: 0; } /* 报告只有指令 / 摘要一段时,那一段的底线也不要 */
.an-full:hover, .an-more:hover { color: var(--ink); background: var(--rowhover); }
.an-full:focus-visible, .an-more:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.an-more:disabled { opacity: .5; cursor: progress; }

/* 卡窄了(手机、被挤的栏):信号 / 步骤两行——圆点 | label | 日期,下一行说明从 label 那一列铺到底;关键数字两列,ref 折到值下面。 */
@container (max-width: 560px) {
  .an-li li { grid-template-columns: 16px minmax(0, 1fr) max-content; row-gap: 2px; }
  .an-li li > :first-child { grid-area: 1 / 1; }
  .an-li .lb { grid-area: 1 / 2; }
  .an-li .dt { grid-area: 1 / 3; }
  .an-li .tx { grid-area: 2 / 2 / 3 / 4; }
  .an-snap { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); column-gap: 14px; }
  .an-snap .r { grid-column: 2; }
}

/* ---------- 主题面板(panel.js) ---------- */
.an-panel { min-width: 0; }
/* 小标题行:「报告」在左,「记忆 ›」在右(.an-lnk,灰色小字按钮)。 */
.an-phead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px var(--an-px) 0; }
.an-phead .an-sub { padding: 0; }
.an-lnk { flex: none; padding: 0; border: 0; background: none; color: var(--sec); font: inherit; font-size: 12.5px; white-space: nowrap; cursor: pointer; }
.an-lnk:hover { color: var(--ink); }
.an-lnk:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.an-panel .an-head { padding-top: 10px; }
.an-panel > .an-none { padding: 10px var(--an-px) 18px; }
/* 往期:每条两行(指令一行,单行省略;「时段名 · 相对时间」一行小字),条与条之间发丝线;整条是链接,新窗口开全文。 */
.an-rows { border-top: 1px solid var(--hair); }
.an-rows > * + * { border-top: 1px solid var(--hair); }
.an-row { display: block; padding: 10px var(--an-px); color: inherit; text-decoration: none; }
.an-row:hover { background: var(--rowhover); }
.an-row:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.an-row .ins { display: block; font-size: 14px; line-height: 1.5; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-row .sub { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; color: var(--sec); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-row.gone { opacity: .55; }
.an-row .gtag { margin-right: 6px; font-size: 12px; color: var(--up); }

/* ---------- 主题弹窗 #mem-dlg(panel.js 建;壳来自 theme.css 的 dialog.dlg) ---------- */
/* 标题里是主题名(动态文本),不用子集衬线。 */
#mem-dlg .dlg-title { font-family: var(--sans); }
/* 记忆列表:label · text · 更新日期,不分小标题。 */
.an-mem { margin: 0; padding: 0 0 6px; list-style: none; }
.an-mem li { display: flex; align-items: baseline; gap: 14px; padding: 9px 0; }
.an-mem .k { flex: none; width: 84px; font-size: 12.5px; color: var(--sec); overflow-wrap: anywhere; }
.an-mem .t { flex: 1; min-width: 0; font-size: 14px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.an-mem .d { flex: none; font: 12px var(--mono); font-variant-numeric: tabular-nums; color: var(--sec); white-space: nowrap; }
.an-mem .none { font-size: 13px; color: var(--sec); }
/* 「启用」一行:字在左、iOS 式开关在右。 */
.an-en { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--hair); cursor: pointer; }
.an-sw { position: relative; flex: none; width: 42px; height: 26px; margin: 0; -webkit-appearance: none; appearance: none; border-radius: 13px; background: var(--hair); cursor: pointer; }
.an-sw::before { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(42, 43, 58, .3); }
.an-sw:checked { background: var(--accent); }
.an-sw:checked::before { transform: translateX(16px); }
.an-sw:disabled { opacity: .45; cursor: not-allowed; }
.an-sw:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* 红字整行「删除主题」:两步确认(第一下变「确认…」,3 秒内再点才做)。 */
#mem-dlg .dlg-destroy { margin-top: 0; }
#mem-dlg .dlg-destroy.armed { border-radius: 10px; background: var(--up-soft); font-weight: 600; }
@media (max-width: 680px) {
  .an-mem li { gap: 10px; }
  .an-mem .k { width: 68px; }
}
@media (prefers-reduced-motion: no-preference) {
  .an-sw { transition: background-color .2s ease; } .an-sw::before { transition: transform .2s cubic-bezier(.16, 1, .3, 1); }
  .an-row, .an-full, .an-more { transition: background-color .15s ease; }
}
