/* AI 助手的思考过程框：进行中是流光边框、呼吸光球和逐条滑入的时间线；结束后收成一张安静的记录卡。 */
@property --trace-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.trace {
  --t-blue: #1787c4; --t-violet: #ea9838; --t-cyan: #30acd8; --t-ease: cubic-bezier(.22, 1, .36, 1);
  position: relative; isolation: isolate; overflow: hidden; margin: 0 0 16px; border-radius: 16px;
  background: linear-gradient(180deg, #fbfcff 0%, #f1f8fb 100%);
  box-shadow: inset 0 0 0 1px #e6eaf4;
  transition: box-shadow .6s var(--t-ease), background .6s var(--t-ease);
}
.trace.live {
  background: #fff;
  box-shadow: inset 0 0 0 1px #d7edf5, 0 22px 48px -28px rgba(18, 116, 165, .6), 0 6px 18px -10px rgba(122, 92, 255, .28);
}

/* 顶部的环境光：两团很淡的蓝紫色，进行中缓慢漂移。 */
.trace::before {
  content: ""; position: absolute; z-index: -1; inset: -60px -20px auto; height: 170px; opacity: 0; pointer-events: none;
  background: radial-gradient(42% 70% at 16% 30%, rgba(18, 116, 165, .16), transparent 72%),
    radial-gradient(38% 70% at 82% 20%, rgba(234, 152, 56, .16), transparent 72%),
    radial-gradient(30% 60% at 52% 0%, rgba(48, 172, 216, .12), transparent 72%);
  transition: opacity .7s ease;
}
.trace.live::before { opacity: 1; animation: trace-drift 7s ease-in-out infinite alternate; }

/* 沿边框转圈的流光。 */
.trace-aura {
  position: absolute; inset: 0; padding: 1.5px; border-radius: inherit; opacity: 0; pointer-events: none;
  background: conic-gradient(from var(--trace-angle), transparent 0 52%, var(--t-cyan) 68%, var(--t-blue) 80%, var(--t-violet) 92%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  transition: opacity .6s ease;
}
.trace.live .trace-aura { opacity: 1; animation: trace-orbit 2.8s linear infinite; }

/* 结束的一瞬间，一道高光从左扫到右。 */
.trace.settled::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-110%);
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .95) 50%, transparent 62%);
  animation: trace-sheen 1s var(--t-ease) 1;
}

/* ---------- 头部 ---------- */
.trace-head {
  position: relative; width: 100%; min-height: 54px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center; gap: 12px; padding: 0 14px; border: 0; background: transparent; color: var(--text-regular);
  font: inherit; text-align: left; cursor: pointer;
}
.trace-head:focus-visible { outline: 2px solid rgba(18, 116, 165, .45); outline-offset: -3px; border-radius: 16px; }
.trace-head .chev { width: 16px; height: 16px; color: #9aa3b8; transition: transform .32s var(--t-ease), color .2s; }
.trace-head:hover .chev { color: var(--t-blue); }
.trace.open .trace-head .chev { transform: rotate(180deg); }

.trace-orb {
  position: relative; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%;
  color: var(--t-blue); background: linear-gradient(135deg, #d7f3ff, #fff1dc); box-shadow: inset 0 0 0 1px rgba(18, 116, 165, .14);
  transition: background .5s ease, box-shadow .5s ease, color .5s ease;
}
.trace-orb svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.trace.live .trace-orb {
  color: #fff; background: radial-gradient(circle at 30% 26%, #6fd4f7 0%, var(--t-blue) 52%, #0e5b81 100%);
  box-shadow: 0 6px 16px -4px rgba(18, 116, 165, .65), inset 0 1px 1px rgba(255, 255, 255, .55);
}
.trace.live .trace-orb svg { animation: trace-twinkle 2.6s ease-in-out infinite; }
.trace.live .trace-orb::before, .trace.live .trace-orb::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%; border: 1.5px solid rgba(18, 116, 165, .5);
  animation: trace-ping 2s cubic-bezier(.2, .7, .3, 1) infinite;
}
.trace.live .trace-orb::after { border-color: rgba(122, 92, 255, .45); animation-delay: 1s; }

.trace-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; white-space: nowrap; }
.trace-title b { flex: none; color: var(--text); font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.trace-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); font-size: 13px; }
/* 进行中的标题：一束彩色的光在文字上来回扫过。 */
.trace.live .trace-title b, .thinking .thinking-label {
  color: transparent; background-size: 300% 100%; -webkit-background-clip: text; background-clip: text;
  animation: trace-shimmer 2.4s linear infinite;
}
.trace.live .trace-title b { background-image: linear-gradient(90deg, #1d2129 0 36%, var(--t-blue) 45%, var(--t-violet) 50%, var(--t-cyan) 55%, #1d2129 64% 100%); }

.trace-meta { display: flex; align-items: center; gap: 6px; }
.trace-chip {
  height: 24px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 12px; color: #52607f; background: #e6f3f8;
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.trace-chip:empty { display: none; }
.trace.live .trace-chip { color: var(--t-blue); background: rgba(18, 116, 165, .08); }

/* ---------- 步骤：展开和收起用网格行高过渡，不跳动 ---------- */
.trace-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .36s var(--t-ease); }
.trace.open .trace-body { grid-template-rows: 1fr; }
.trace-clip { min-height: 0; overflow: hidden; }
.trace-steps { position: relative; margin: 0; padding: 6px 12px 12px; list-style: none; }
.trace-steps::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 14px; height: 1px;
  background: linear-gradient(90deg, transparent, #dfe5f3 12%, #dfe5f3 88%, transparent);
}
.step, .thinking {
  position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 40px; padding: 4px 10px 4px 2px; border-radius: 10px;
}
.step { cursor: pointer; transition: background .16s ease; }
.step:hover { background: rgba(18, 116, 165, .055); }
/* 时间线：从上一步的圆点连到这一步的圆点。 */
.step::before, .thinking::before {
  content: ""; position: absolute; left: 15.5px; top: -50%; width: 1px; height: 100%;
  background: linear-gradient(180deg, #c2e3ef, #e2e7f5);
}
.trace-steps > li:first-child::before { display: none; }
.step-icon {
  position: relative; z-index: 1; justify-self: center; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%;
  color: var(--t-blue); background: linear-gradient(135deg, #d4f2ff, #fff1dc); box-shadow: 0 0 0 3px #fff, inset 0 0 0 1px rgba(18, 116, 165, .18);
}
.trace:not(.live) .step-icon { box-shadow: 0 0 0 3px #f5fafc, inset 0 0 0 1px rgba(18, 116, 165, .18); }
.step-icon svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* 没成的步骤：灰一档，不用红色（2026-11-28 负责人说两个红色感叹号不好看）。 */
.step.fail .step-icon, .trace:not(.live) .step.fail .step-icon { color: #9aa3b2; background: #f3f5f8; box-shadow: 0 0 0 3px #f5fafc, inset 0 0 0 1px rgba(120, 132, 150, .28); }
.step.fail .step-main b { color: var(--text-muted); font-weight: 500; }
.step-miss { margin-left: 8px; padding: 0 8px; border-radius: 99px; color: #8a6a3a; background: var(--accent-soft); font-size: 11.5px; line-height: 18px; }
.step-main { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-regular); font-size: 13px; }
.step-main b { color: var(--text); font-weight: 600; }
.step-main .params { margin-left: 6px; color: var(--text-muted); }
.step-main .arrow { margin: 0 8px; color: #b9c2d8; }
.step-main .result { color: #3d4a68; }
.step-ms { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.step:hover .step-ms { color: var(--t-blue); }
/* 新查到的一步：从下方带着一点模糊滑进来，圆点弹一下。 */
.step.enter { animation: trace-step-in .55s var(--t-ease) both; }
.step.enter .step-icon { animation: trace-pop .6s cubic-bezier(.3, 1.7, .5, 1) both; }

.thinking { color: var(--text-muted); font-size: 13px; }
.thinking-ring {
  position: relative; z-index: 1; justify-self: center; width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 22%, var(--t-cyan), var(--t-blue), var(--t-violet));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2px));
  animation: trace-rotate .9s linear infinite;
}
.thinking .thinking-label { background-image: linear-gradient(90deg, #8a90a0 0 38%, #1d2129 50%, #8a90a0 62% 100%); }

#assistant.au-quick .trace-sub { display: none; }
@media (max-width: 600px) { .trace-sub { display: none; } }

@keyframes trace-orbit { to { --trace-angle: 360deg; } }
@keyframes trace-rotate { to { transform: rotate(360deg); } }
@keyframes trace-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes trace-drift { from { transform: translate3d(-3%, 0, 0); } to { transform: translate3d(3%, 6px, 0); } }
@keyframes trace-ping { 0% { transform: scale(1); opacity: .9; } 80%, 100% { transform: scale(1.75); opacity: 0; } }
@keyframes trace-twinkle { 0%, 100% { transform: scale(1) rotate(0deg); } 50% { transform: scale(1.14) rotate(18deg); } }
@keyframes trace-sheen { to { transform: translateX(110%); } }
@keyframes trace-step-in { from { opacity: 0; transform: translateY(10px); filter: blur(5px); } }
@keyframes trace-pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .trace, .trace *, .trace::before, .trace::after { animation: none !important; transition: none !important; }
  .trace.live .trace-aura { background: linear-gradient(135deg, var(--t-cyan), var(--t-blue), var(--t-violet)); }
  .trace.live .trace-title b, .thinking .thinking-label { color: var(--text); background: none; }
}
