/* ────────────────────────────────────────────────
   阿凯
   参考 Linear 的中性灰阶与克制程度：
   强调色只出现在圆点级别、1px 低对比边框分层、小圆角、无阴影
   ──────────────────────────────────────────────── */

:root {
  --bg:        #FAFAFA;   /* 中性近白，不带暖黄 */
  --surface:   #F1F1F2;   /* 他的气泡：灰一层，不加边框 */
  --surface-2: #FFFFFF;

  --fg:        #18181B;
  --fg-2:      #52525B;
  --fg-3:      #A1A1AA;

  --line:      #E4E4E7;
  --line-2:    #EFEFF1;

  --me:        #18181B;
  --me-fg:     #FAFAFA;

  --ease:      cubic-bezier(.25,.46,.45,.94);
  --font:      "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ───────── 全屏渲染 ───────── */
/* ───────── 开机：欢迎语 + 真实加载进度 ───────── */
#bg {
  opacity: 0;
  transition: opacity .9s var(--ease);
}
#bg.in { opacity: 1; }

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  cursor: grab;
}
#bg:active { cursor: grabbing; }

.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(250,250,250,0)    0%,
    rgba(250,250,250,0)    42%,
    rgba(250,250,250,.38)  54%,
    rgba(250,250,250,.84)  64%,
    rgba(250,250,250,.98)  72%,
    var(--bg)              80%);
}

/* ───────── 开机层：一条竖线 + 一个词 + 一条进度 ───────── */
.boot {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;   /* 文字块钉在下方，上半屏留给粒子人形 */
  padding-bottom: 17vh;
  gap: 0;
  background: var(--bg);
  transition: opacity .65s var(--ease), visibility .65s;
}
.boot.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot.done .boot-inner {
  transform: translateY(-10px);
}
.boot-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform .65s var(--ease);
}
#bootFx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* 顶上一条会自己画出来的竖线，给整块一个起点 */
.boot-rule {
  width: 1px;
  height: 0;
  background: var(--fg-3);
  margin-bottom: 26px;
  animation: bootRule 1s var(--ease) .1s forwards;
}
@keyframes bootRule {
  to { height: 34px; }
}
.boot-word {
  margin: 0 0 34px;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: .18em;
  text-indent: .18em;   /* 抵消末字符字距，保持视觉居中 */
  color: var(--fg);
  display: flex;
}
.boot-word span {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px);
  filter: blur(6px);
  animation: bootIn .9s var(--ease) forwards;
  animation-delay: calc(var(--i) * 110ms + 350ms);
}
@keyframes bootIn {
  to { opacity: 1; transform: none; filter: none; }
}
.boot-foot {
  display: flex;
  align-items: center;
  gap: 14px;
}
.boot-track {
  width: 220px;
  height: 1px;
  background: var(--line-2);
  overflow: hidden;
}
.boot-track i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--fg-3);
  transition: width .12s linear;
}
.boot-pct {
  font-size: 11px;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  min-width: 3.2em;
}

/* ───────── 顶栏 ───────── */
.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 clamp(20px, 4vw, 44px);
  pointer-events: none;
}
.top::after {
  content: "";
  position: absolute;
  left: clamp(20px, 4vw, 44px);
  right: clamp(20px, 4vw, 44px);
  bottom: 0;
  height: 1px;
  background: var(--line-2);
}
/* 状态用字形表达，不用发光 */
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22C55E;
  flex: none;
}
.name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.state {
  font-size: 12px;
  color: var(--fg-3);
}

/* ───────── 内容层 ───────── */
.layer {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding-top: 52px;
  pointer-events: none;
}

.col {
  flex: 1;
  width: min(640px, 56vw);
  margin-left: 30%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  pointer-events: auto;
}

/* ───────── 对话 ───────── */
.scroll {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 10%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 10%, #000 100%);
}
.scroll::-webkit-scrollbar { display: none; }

.thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin: auto 0;
  padding: 10px 0;
}

/* ───────── 气泡：只靠一层底色区分，不加边框不加阴影 ───────── */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: rise .28s var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.static .msg { animation: none !important; }

.msg.bot .body {
  background: var(--surface);
  color: var(--fg);
  border-radius: 10px 10px 10px 3px;
  padding: 11px 14px 12px;
  font-size: 14.5px;
  line-height: 1.7;
}
.msg.bot .body > p { margin: 0 0 7px; }
.msg.bot .body > p:last-child { margin-bottom: 0; }

.msg.bot.lead .body {
  font-size: 16px;
  line-height: 1.68;
  font-weight: 500;
  padding: 13px 15px 14px;
  letter-spacing: -0.008em;
}

.msg.me { align-self: flex-end; }
.msg.me .body {
  background: var(--me);
  color: var(--me-fg);
  border-radius: 10px 10px 3px 10px;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.65;
}

.msg.bot .body em { font-style: normal; color: var(--fg); font-weight: 500; }

/* ───────── 气泡里的信息块：去掉编号，只留两列 ───────── */
.list {
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}
.list li {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--line-2);
  font-size: 13px;
  line-height: 1.68;
  color: var(--fg-2);
}
.list li:first-child { border-top: 0; padding-top: 2px; }
.list li b {
  color: var(--fg-3);
  font-weight: 400;
  font-size: 12px;
}

.cards { display: grid; gap: 6px; margin-top: 10px; }
.card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px 11px;
}
.card-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 2px;
}
.card-name { font-size: 13px; font-weight: 500; color: var(--fg); }
.card-tag { font-size: 10.5px; color: var(--fg-3); white-space: nowrap; flex: none; }
.card-desc { margin: 0; font-size: 12.5px; line-height: 1.62; color: var(--fg-2); }

.cards + p, .list + p { margin-top: 10px !important; }

/* 打字指示 */
.typing { display: flex; gap: 4px; padding: 4px 0; }
.typing i {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--fg-3);
  animation: bob 1.2s var(--ease) infinite;
}
.typing i:nth-child(2) { animation-delay: .14s; }
.typing i:nth-child(3) { animation-delay: .28s; }
@keyframes bob {
  0%,100% { opacity: .3; transform: translateY(0) }
  40%     { opacity: 1;  transform: translateY(-2px) }
}

/* ───────── agent：工具条 ───────── */
/* 只用既有 token：1px 低对比边框、小圆角、无阴影、无渐变 */
.acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}
.act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1;
  color: var(--fg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  white-space: nowrap;
}
.act i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--fg-3);
  flex: none;
}
.act b { font-weight: 400; }
.act[data-status="completed"] i { background: #22C55E; }
.act[data-status="in_progress"] i {
  background: var(--fg-3);
  animation: pulse 1.1s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: 1; }
}

/* ───────── agent：正文 ───────── */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 7px; }
.md h3, .md h4, .md h5, .md h6 {
  margin: 12px 0 6px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.004em;
  color: var(--fg);
}
.md h4, .md h5, .md h6 { font-size: 12.5px; color: var(--fg-2); }
.md ul, .md ol {
  margin: 4px 0 8px;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.68;
}
.md li { margin: 2px 0; }
.md li::marker { color: var(--fg-3); }
.md strong { font-weight: 600; color: var(--fg); }
.md em { font-style: normal; font-weight: 500; color: var(--fg); }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}
.md pre.code {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}
.md pre.code code {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.62;
  color: var(--fg-2);
}
.md blockquote {
  margin: 8px 0;
  padding: 2px 0 2px 12px;
  border-left: 1px solid var(--line);
  color: var(--fg-2);
  font-size: 13.5px;
}
.md .tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12.5px;
}
.md .tbl th, .md .tbl td {
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
.md .tbl th {
  color: var(--fg-3);
  font-weight: 400;
  font-size: 11.5px;
  white-space: nowrap;
}
.md .tbl td { color: var(--fg-2); }
.md .err { color: #C2410C; }

/* 流式输出时的呼吸光标 */
.md.streaming > *:last-child::after {
  content: "";
  display: inline-block;
  width: 6px; height: 13px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--fg-3);
  animation: caret 1s steps(2, start) infinite;
}
@keyframes caret {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ───────── 输入区 ───────── */
.dock { flex: none; padding: 10px 0 18px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chip {
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--fg-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.chip:hover { color: var(--fg); border-color: #C9C9CF; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 6px 5px 13px;
  transition: border-color .15s var(--ease);
}
.composer:focus-within { border-color: #B8B8C0; }

.composer textarea {
  flex: 1;
  border: 0; outline: 0; resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  color: var(--fg);
  padding: 8px 0;
  max-height: 96px;
}
.composer textarea::placeholder { color: var(--fg-3); }

.send {
  flex: none;
  width: 30px; height: 30px;
  border: 0; border-radius: 6px;
  background: var(--me);
  color: var(--me-fg);
  display: grid; place-items: center;
  cursor: pointer;
  margin-bottom: 1px;
  transition: opacity .15s var(--ease), transform .12s var(--ease);
}
.send svg { width: 14px; height: 14px; }
.send:hover { opacity: .85; }
.send:active { transform: scale(.95); }

.note {
  margin: 8px 0 0;
  font-size: 11px;
  letter-spacing: -0.002em;
  color: #B4B4BA;
}

/* 模型加载失败提示：居中一块，写清原因和出路 */
.load-error {
  position: fixed;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  z-index: 9;
  max-width: 400px;
  padding: 18px 22px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 28px rgba(24,24,27,.10);
}
.load-error b { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.load-error span { font-size: 12.5px; line-height: 1.8; color: var(--fg-2); }
.load-error code {
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ───────── 窄屏 ───────── */
@media (max-width: 860px) {
  .veil {
    background: linear-gradient(180deg,
      rgba(250,250,250,0)    0%,
      rgba(250,250,250,.02)  20%,
      rgba(250,250,250,.62)  32%,
      rgba(250,250,250,.95)  42%,
      var(--bg)              54%);
  }
  .top { height: 48px; }
  .layer { padding-top: 48px; }
  .col { width: auto; margin-left: 0; padding: 0 16px; }
  .scroll { flex: 1 1 0; }
  .msg { max-width: 94%; }
  .msg.bot.lead .body { font-size: 15px; }
  .chips { gap: 5px; }
  .chip { padding: 6px 9px; font-size: 11.5px; }
  .list li { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; font-size: 12.5px; }
  .dock { padding: 8px 0 14px; }
}
