/* =========================================================
   李俊霖 · AI 数字分身
   设计基调：白色为主 · 简洁 · 专业 · 现代
   ========================================================= */

:root {
  --ink: #131a2c;
  --muted: #58637c;
  --dim: #8a93a8;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --soft: #f3f6fb;
  --line: #e5e9f2;
  --line-strong: #d8deea;
  --accent: #3b5bfd;
  --accent-strong: #2c49e8;
  --accent-soft: #eef2ff;
  --accent-line: #cbd6fe;
  --success: #1c9a62;
  --success-soft: #ecf9f2;
  --success-line: #c9ecd9;
  --warning: #a86a0b;
  --warning-soft: #fdf5e6;
  --warning-line: #f2e2bd;

  --topbar-h: 72px;
  --radius-pane: 20px;
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow-sm: 0 1px 2px rgba(19, 26, 44, 0.05), 0 2px 8px rgba(19, 26, 44, 0.04);
  --shadow-md: 0 2px 6px rgba(19, 26, 44, 0.05), 0 16px 36px rgba(19, 26, 44, 0.08);
  --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(720px 320px at 12% -6%, rgba(59, 91, 253, 0.05), transparent 70%),
    radial-gradient(820px 380px at 96% 108%, rgba(59, 91, 253, 0.06), transparent 70%),
    var(--bg);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { color: #fff; background: var(--accent); }
img { display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.25s ease;
}
.topbar.is-scrolled { box-shadow: 0 6px 24px rgba(19, 26, 44, 0.06); }
.topbar-inner {
  width: min(1280px, calc(100% - 64px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 28%;
  box-shadow: 0 0 0 1px var(--line), 0 4px 12px rgba(19, 26, 44, 0.1);
}
.brand-text { display: grid; gap: 1px; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.brand-text span { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; }

.disclosure {
  margin: 0;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid var(--success-line);
  border-radius: 999px;
  background: var(--success-soft);
  color: #157a4c;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.status-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.status-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--success);
  animation: dot-pulse 2.2s ease-out infinite;
}

/* ---------- 通用 ---------- */
.mono {
  margin: 0 0 8px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
h1, h2 { margin: 0; font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: 0.01em; }

/* ---------- 工作区布局 ---------- */
.workspace {
  width: min(1280px, calc(100% - 64px));
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 24px;
}
.project-pane, .chat-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pane);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: panel-in 0.5s cubic-bezier(0.22, 0.68, 0.26, 1) both;
}
.chat-pane { animation-delay: 0.08s; }
.pane-heading, .chat-header {
  flex: none;
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}
.count {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}
.chat-hint { margin: 0; color: var(--dim); font-size: 12px; letter-spacing: 0.04em; }

/* ---------- 项目列表 ---------- */
.project-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-card {
  position: relative;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.22s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.project-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.project-index {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 26px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  transition: background 0.22s ease, color 0.22s ease;
}
.project-card:hover .project-index { background: var(--accent); color: #fff; }
.project-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.project-open svg { width: 13px; height: 13px; }
.project-card:hover .project-open,
.project-card:focus-visible .project-open { opacity: 1; transform: translateX(0); }
.project-title { margin: 0 0 8px; font-size: 16.5px; font-weight: 700; line-height: 1.5; }
.project-focus { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.75; }
.project-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.project-role {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 500;
}
.project-stack { color: var(--dim); font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; }
.list-error { margin: 24px 8px; color: var(--muted); font-size: 13.5px; text-align: center; }

@media (hover: none) {
  .project-open { opacity: 1; transform: none; }
}

/* ---------- 骨架屏 ---------- */
.project-skeleton {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  display: grid;
  gap: 10px;
  justify-items: start;
}
.sk {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #edf0f7 25%, #f8fafd 50%, #edf0f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.sk-index { width: 30px; height: 26px; border-radius: 8px; }
.sk-line.w-45 { width: 45%; }
.sk-line.w-70 { width: 70%; }
.sk-line.w-95 { width: 95%; }

/* ---------- 问答消息 ---------- */
.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 28px 10px;
  scrollbar-width: thin;
  scrollbar-color: #ccd4e2 transparent;
}
.message { display: flex; gap: 10px; margin-bottom: 22px; animation: message-in 0.32s ease both; }
.message-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  margin-top: 20px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 28%;
  box-shadow: 0 0 0 1px var(--line);
}
.message-body { max-width: 78%; min-width: 0; }
.message.user { justify-content: flex-end; }
.message.user .message-body { display: flex; flex-direction: column; align-items: flex-end; }
.message-label {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
}
.message.user .message-label { color: var(--dim); }
.message-time { margin-left: 8px; color: var(--dim); letter-spacing: 0.06em; }
.bubble {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  background: var(--soft);
  color: #333c52;
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.message.user .bubble {
  border-color: transparent;
  border-radius: 16px 4px 16px 16px;
  background: linear-gradient(135deg, var(--accent), #5a78ff);
  color: #fff;
  box-shadow: 0 8px 20px rgba(59, 91, 253, 0.2);
}
.bubble strong { font-weight: 700; color: var(--ink); }
.message.user .bubble strong { color: #fff; }

/* 打字指示器 */
.bubble.typing { display: inline-flex; align-items: center; gap: 5px; padding: 15px 18px; }
.bubble.typing .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.bubble.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing .dot:nth-child(3) { animation-delay: 0.3s; }

/* 证据引用与提示 */
.citations { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.citations-caption { color: var(--dim); font-size: 11px; letter-spacing: 0.06em; }
.citation {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.agent-trace {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11.5px;
}
.agent-trace summary {
  width: fit-content;
  cursor: pointer;
  color: var(--dim);
  line-height: 1.6;
  user-select: none;
}
.agent-trace summary:hover { color: var(--accent); }
.agent-trace ol {
  margin: 7px 0 0;
  padding: 8px 12px 8px 28px;
  border-left: 2px solid var(--accent-soft);
  background: #fafbfe;
  line-height: 1.7;
}
.agent-trace li + li { margin-top: 2px; }
.needs-review {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--warning-line);
  border-radius: 10px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- 输入区 ---------- */
.chat-form {
  flex: none;
  margin: 6px 20px 0;
  padding: 8px 8px 8px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}
.chat-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm); }
.chat-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 26px;
  max-height: 150px;
  margin: 7px 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.65;
  field-sizing: content;
}
.chat-form textarea::placeholder { color: #a2a9ba; }
.chat-form button {
  flex: none;
  height: 40px;
  min-width: 92px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-btn);
  background: linear-gradient(135deg, var(--accent), #5673ff);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(59, 91, 253, 0.24);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.chat-form button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(59, 91, 253, 0.3);
  filter: brightness(1.04);
}
.chat-form button:active:not(:disabled) { transform: translateY(0); }
.chat-form button:disabled { opacity: 0.55; cursor: wait; box-shadow: none; }
.send-icon { width: 15px; height: 15px; transition: transform 0.18s ease; }
.chat-form button:hover:not(:disabled) .send-icon { transform: translate(1.5px, -1.5px); }

/* ---------- 反馈 ---------- */
.feedback-slot { flex: none; min-height: 54px; padding: 10px 24px 14px; display: flex; align-items: center; }
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.feedback-q { margin-right: 2px; color: var(--dim); font-size: 12.5px; }
.feedback button {
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.feedback button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.feedback button:disabled { opacity: 0.5; cursor: default; }
.correction-input {
  flex: 1;
  min-width: 180px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: 0;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.correction-input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.feedback-done { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- 项目详情抽屉 ---------- */
.project-dialog {
  width: min(620px, 100vw);
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: -28px 0 90px rgba(15, 23, 42, 0.2);
}
.project-dialog[open] { animation: drawer-in 0.32s cubic-bezier(0.22, 0.68, 0.26, 1) both; }
.project-dialog::backdrop { background: rgba(17, 24, 39, 0.32); backdrop-filter: blur(4px); }
.dialog-shell { position: relative; height: 100%; overflow-y: auto; padding: 52px clamp(26px, 5vw, 54px) 56px; }
.dialog-close {
  position: absolute;
  top: 20px;
  right: 22px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.25s ease;
}
.dialog-close:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); transform: rotate(90deg); }
#project-detail > h2 {
  margin: 0 0 16px;
  padding-right: 40px;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.detail-stack { color: var(--dim); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; }
#project-detail section { padding: 22px 0; border-bottom: 1px solid var(--line); }
#project-detail section:last-child { border-bottom: 0; }
#project-detail section h3 { position: relative; margin: 0 0 12px; padding-left: 12px; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; }
#project-detail section h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
#project-detail section p, #project-detail li { color: #4a5468; font-size: 14.5px; line-height: 1.95; }
#project-detail section p { margin: 0; }

/* 架构流程：编号时间线 */
.detail-arch { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.detail-arch li { counter-increment: step; position: relative; padding: 0 0 16px 42px; }
.detail-arch li:last-child { padding-bottom: 2px; }
.detail-arch li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.detail-arch li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 32px;
  bottom: 2px;
  width: 1px;
  background: var(--line-strong);
}

/* 实现重点：勾选列表 */
.detail-highlights { margin: 0; padding: 0; list-style: none; }
.detail-highlights li { position: relative; padding: 0 0 10px 30px; }
.detail-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b5bfd' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 9px no-repeat;
}

/* ---------- 滚动条 ---------- */
.messages::-webkit-scrollbar, .project-list::-webkit-scrollbar, .dialog-shell::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .project-list::-webkit-scrollbar-thumb, .dialog-shell::-webkit-scrollbar-thumb {
  background: #d3dae6;
  border-radius: 8px;
  border: 2px solid var(--surface);
}
.messages::-webkit-scrollbar-thumb:hover, .project-list::-webkit-scrollbar-thumb:hover, .dialog-shell::-webkit-scrollbar-thumb:hover { background: #bcc6d8; }

/* ---------- 动画 ---------- */
@keyframes panel-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes message-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes drawer-in { from { opacity: 0.4; transform: translateX(56px); } to { opacity: 1; transform: translateX(0); } }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes dot-pulse { 0% { transform: scale(0.6); opacity: 0.7; } 70% { transform: scale(1.15); opacity: 0; } 100% { opacity: 0; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- 平板 / 移动端 ---------- */
@media (max-width: 960px) {
  :root { --topbar-h: 64px; }
  .topbar-inner { width: calc(100% - 32px); }
  .workspace {
    width: min(100% - 28px, 640px);
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 0 24px;
  }
  .chat-pane { order: 1; height: calc(100dvh - var(--topbar-h) - 28px); min-height: 520px; }
  .project-pane { order: 2; }
  .project-list { overflow: visible; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .topbar-inner { width: calc(100% - 28px); }
  .brand { gap: 10px; }
  .brand img { width: 38px; height: 38px; }
  .brand-text strong { font-size: 15px; }
  .brand-text span { font-size: 11px; }
  .disclosure { padding: 6px 11px; gap: 6px; font-size: 11px; }
  .workspace { width: calc(100% - 20px); gap: 12px; padding: 10px 0 20px; }
  .project-pane, .chat-pane { border-radius: 16px; }
  .pane-heading, .chat-header { padding: 16px 18px; }
  h1, h2 { font-size: 21px; }
  .chat-hint { display: none; }
  .chat-pane { height: calc(100dvh - var(--topbar-h) - 20px); min-height: 480px; }
  .messages { padding: 18px 16px 8px; }
  .message { margin-bottom: 18px; }
  .message-body { max-width: 88%; }
  .bubble { padding: 11px 14px; font-size: 14.5px; }
  .chat-form { margin: 4px 12px 0; padding: 6px 6px 6px 14px; border-radius: 14px; }
  .chat-form textarea { font-size: 14.5px; }
  .chat-form button { min-width: 74px; height: 38px; padding: 0 12px; font-size: 12.5px; }
  .feedback-slot { padding: 8px 16px 12px; }
  .project-list { padding: 12px; }
  .project-card { padding: 16px; }
  .project-open { opacity: 1; transform: none; }
  .project-dialog { width: 100vw; }
  .dialog-shell { padding: 56px 20px 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
