:root {
  --ms-blue: #0071e3;
  --ms-blue-deep: #0058b0;
  --ms-blue-soft: #5eb1ff;
  --ms-ink: #1a1d24;
  --ms-ink-2: #3a3f4b;
  --ms-muted: #6b7280;
  --ms-line: rgba(26, 29, 36, 0.08);
  --ms-line-strong: rgba(26, 29, 36, 0.12);
  --ms-bg: #eef1f6;
  --ms-panel: rgba(255, 255, 255, 0.78);
  --ms-card: #ffffff;
  --ms-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 14px rgba(16, 24, 40, 0.04);
  --ms-shadow: 0 2px 8px rgba(16, 24, 40, 0.04), 0 16px 40px rgba(16, 24, 40, 0.07);
  --ms-shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.1), 0 32px 80px rgba(0, 113, 227, 0.08);
  --ms-radius: 18px;
  --ms-radius-sm: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-num: "SF Pro Display", "DIN Alternate", "Tabular Numbers", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #d5dae3 transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: #d5dae3; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #bfc6d4; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ms-ink);
  background: var(--ms-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ms-muted); }
.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-blue);
  font-weight: 650;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: -0.01em;
  transition: transform 0.18s var(--ease), background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, opacity 0.15s ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #1a82ef 0%, var(--ms-blue) 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 8px 20px rgba(0,113,227,0.28);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #1676db 0%, var(--ms-blue-deep) 100%);
  transform: translateY(-1px);
}
.btn-ghost {
  background: rgba(255,255,255,0.7);
  color: var(--ms-ink-2);
  border: 1px solid var(--ms-line-strong);
  box-shadow: var(--ms-shadow-sm);
}
.btn-ghost:hover { color: var(--ms-ink); background: #fff; border-color: rgba(0,113,227,0.25); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }

.field {
  width: 100%;
  border: 1px solid var(--ms-line-strong);
  border-radius: 12px;
  padding: 11px 14px;
  background: rgba(255,255,255,0.92);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  color: var(--ms-ink);
}
.field:focus {
  border-color: rgba(0,113,227,0.55);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
}
.form-error { color: #c41e3a; font-size: 13px; margin: 8px 0; }

.glass {
  background: var(--ms-panel);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: var(--ms-shadow-lg);
}

/* Login 样式见 assets/login.css */

/* App shell */
.app-page { overflow: hidden; }
.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 268px 1fr;
  height: 100vh;
  background:
    radial-gradient(1000px 480px at 100% -10%, rgba(0,113,227,0.11), transparent 55%),
    radial-gradient(780px 420px at 0% 100%, rgba(30, 58, 95, 0.06), transparent 50%),
    linear-gradient(180deg, #f3f5f9 0%, #e9edf4 100%);
}
.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.sidebar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  border-right: 1px solid rgba(255,255,255,0.55);
  background: linear-gradient(180deg, rgba(255,255,255,0.86) 0%, rgba(248,250,253,0.78) 100%);
  backdrop-filter: blur(22px) saturate(1.15);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  box-shadow: 8px 0 40px rgba(16, 24, 40, 0.04);
  min-height: 0;
  overflow: hidden;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 10px 18px;
}
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2b8df0, #005bb5);
  color: #fff;
  box-shadow: 0 10px 24px rgba(0,113,227,0.32), 0 1px 0 rgba(255,255,255,0.25) inset;
  flex-shrink: 0;
}
.brand-mark svg { width: 22px; height: 22px; display: block; }
.brand-title {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 11px;
  color: var(--ms-muted);
  margin-top: 3px;
  letter-spacing: 0.01em;
}

.nav-group { margin-bottom: 10px; }
.nav-group-label {
  padding: 4px 12px 8px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  color: #9aa3b2;
  text-transform: uppercase;
}

.side-nav {
  display: block;
  flex: 1;
  overflow: auto;
  padding-right: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ms-ink-2);
  padding: 8px 10px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 3px;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s var(--ease);
}
.nav-item:hover {
  background: rgba(255,255,255,0.72);
  color: var(--ms-ink);
  border-color: rgba(0,113,227,0.08);
}
.nav-item:hover .nav-ico {
  background: rgba(0,113,227,0.12);
  color: var(--ms-blue);
  transform: translateY(-1px);
}
.nav-item.active {
  background: #fff;
  color: var(--ms-blue);
  font-weight: 620;
  border-color: rgba(0,113,227,0.18);
  box-shadow: var(--ms-shadow-sm);
}
.nav-item.active .nav-ico {
  background: linear-gradient(145deg, #3a97f5, #0066cc);
  color: #fff;
  box-shadow: 0 5px 14px rgba(0,113,227,0.3);
}
.nav-ico {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 29, 36, 0.04);
  color: inherit;
  transition: transform 0.18s var(--ease), background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.nav-ico svg { width: 17px; height: 17px; display: block; }
.nav-ico.sm { width: 20px; height: 20px; border-radius: 6px; background: transparent; }
.nav-ico.sm svg { width: 15px; height: 15px; }
.nav-link-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  margin-bottom: 8px;
}
.side-foot {
  padding-top: 14px;
  border-top: 1px solid var(--ms-line);
  margin-top: 6px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--ms-line);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #dce9fb, #b9d4f7);
  color: var(--ms-blue-deep);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-line {
  font-size: 12px;
  color: var(--ms-ink-2);
  line-height: 1.35;
  min-width: 0;
}
.user-line small {
  display: block;
  color: var(--ms-muted);
  font-size: 11px;
  margin-top: 2px;
}

.main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 26px 32px 14px;
}
.topbar-left { min-width: 0; }
.topbar-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8b95a8;
}
.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.035em;
  font-weight: 720;
  line-height: 1.15;
}
.topbar .muted {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--ms-muted);
  max-width: 520px;
  line-height: 1.45;
}
.topbar-meta {
  font-size: 12px;
  color: var(--ms-muted);
  text-align: right;
  max-width: 300px;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: var(--ms-shadow-sm);
  backdrop-filter: blur(10px);
}

.view-host {
  flex: 1;
  min-height: 0;
  padding: 8px 32px 32px;
  overflow: auto;
}
.view-enter {
  animation: viewIn 0.35s var(--ease);
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Board */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: var(--ms-radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(252,253,255,0.96));
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--ms-shadow);
  overflow: hidden;
  transition: transform 0.22s var(--ease), box-shadow 0.22s ease;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ms-blue-soft), var(--ms-blue));
}
.kpi:nth-child(2)::before { background: linear-gradient(180deg, #ffb347, #f0851a); }
.kpi:nth-child(3)::before { background: linear-gradient(180deg, #ff8a7a, #e85d4c); }
.kpi:nth-child(4)::before { background: linear-gradient(180deg, #6ed39a, #2f9e5f); }
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--ms-shadow-lg);
}
.kpi .label {
  font-size: 12.5px;
  color: var(--ms-muted);
  font-weight: 550;
  padding-left: 8px;
}
.kpi .value {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 720;
  margin-top: 8px;
  letter-spacing: -0.04em;
  padding-left: 8px;
  color: var(--ms-ink);
}
.kpi .hint {
  font-size: 11px;
  color: #9aa3b2;
  margin-top: 10px;
  padding-left: 8px;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(252,253,255,0.95));
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--ms-radius);
  padding: 20px 20px 18px;
  margin-bottom: 14px;
  box-shadow: var(--ms-shadow);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  font-weight: 680;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ms-blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--ms-line);
}
.table th {
  color: #8b95a8;
  font-weight: 620;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(245,247,251,0.8);
}
.table thead th:first-child { border-radius: 10px 0 0 10px; }
.table thead th:last-child { border-radius: 0 10px 10px 0; }
.table tbody tr { transition: background 0.15s ease; }
.table tbody tr:hover td { background: rgba(0,113,227,0.03); }
.table tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,113,227,0.1);
  color: var(--ms-blue-deep);
}
.badge.warn { background: rgba(255,149,0,0.14); color: #b85a00; }
.badge.ok { background: rgba(52,199,89,0.14); color: #1f7a3a; }
.source-note {
  font-size: 12px;
  color: #8b95a8;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--ms-line-strong);
  line-height: 1.5;
}

/* Ask chat — aligned with 粮专家智能问答 */
body.ask-focused .topbar {
  padding: 14px 24px 6px;
}
body.ask-focused .topbar h1 { font-size: 20px; }
body.ask-focused .topbar .muted { display: none; }
body.ask-focused .view-host {
  padding: 4px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
body.ask-focused .view-host > .ask-shell {
  flex: 1;
  min-height: 0;
}
body.ask-expanded .sidebar { display: none; }
body.ask-expanded .app-shell { grid-template-columns: 1fr; }
body.ask-expanded .topbar { display: none; }
body.ask-expanded .view-host { padding: 10px 14px 12px; height: 100vh; }

.ask-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
  height: calc(100vh - 118px);
  min-height: 480px;
  position: relative;
}
.history-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 40;
}
.history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow);
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.history-head h2 { margin: 0; font-size: 15px; }
.chat-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.chat-item {
  position: relative;
  text-align: left;
  border: 1px solid transparent;
  background: #f5f7fb;
  border-radius: 12px;
  padding: 10px 36px 10px 10px;
  cursor: pointer;
  color: var(--ms-ink);
  font: inherit;
  transition: border-color .15s ease, background .15s ease;
}
.chat-item:hover { border-color: rgba(0,113,227,0.35); }
.chat-item.active {
  border-color: rgba(0,113,227,0.55);
  background: rgba(0,113,227,0.1);
}
.chat-item .t {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item .m {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ms-muted);
}
.chat-item .conv-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ms-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  font-size: 16px;
  line-height: 1;
}
.chat-item:hover .conv-del,
.chat-item.active .conv-del { opacity: 1; }
.chat-item .conv-del:hover {
  background: rgba(255,69,58,0.12);
  color: #c41e3a;
}
.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,253,0.94));
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: var(--ms-radius);
  box-shadow: var(--ms-shadow);
  padding: 12px 14px 12px;
}
.chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.chat-toolbar .muted { display: block; font-size: 12px; margin-top: 2px; color: var(--ms-muted); }
.chat-title-wrap { min-width: 0; flex: 1; }
.title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-title-text {
  max-width: min(420px, 55vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.title-input {
  max-width: min(420px, 55vw);
  height: 32px;
  padding: 4px 10px;
  font-size: 14px;
}
.toolbar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar-actions .icon-btn.tiny {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--ms-muted);
}
.toolbar-actions .icon-btn.tiny:hover { color: var(--ms-blue); }
#btnDeleteChat:hover { color: #c41e3a; border-color: rgba(196,30,58,0.35); background: rgba(196,30,58,0.08); }
.history-toggle { display: none; }
.chat-stream {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 10px;
  min-height: 0;
}
.chat-stream:has(.bubble:only-child.system) { justify-content: center; }
.bubble {
  max-width: min(920px, 100%);
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 16px;
  word-break: break-word;
  box-shadow: none;
}
.bubble.user {
  align-self: flex-end;
  background: rgba(0,113,227,0.08);
  color: var(--ms-ink);
  border: 1px solid rgba(0,113,227,0.28);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
}
.bubble.assistant {
  align-self: flex-start;
  background: #f5f7fb;
  border: 1px solid var(--ms-line);
  border-bottom-left-radius: 6px;
  white-space: normal;
}
.bubble.system {
  align-self: center;
  max-width: min(520px, 92%);
  text-align: center;
  background: transparent;
  border: 0;
  color: var(--ms-muted);
  font-size: 13.5px;
  box-shadow: none;
}
.bubble .md p,
.bubble .md-body p { margin: 0 0 8px; }
.bubble .md p:last-child,
.bubble .md-body p:last-child { margin-bottom: 0; }
.bubble .md ul,
.bubble .md-body ul { margin: 6px 0; padding-left: 18px; }
.md-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--ms-ink);
}
.md-body .md-cite {
  color: var(--ms-blue);
  font-weight: 650;
  font-size: 0.92em;
  text-decoration: none;
  cursor: pointer;
  padding: 0 1px;
  border-radius: 4px;
}
.md-body .md-cite:hover {
  background: rgba(0,113,227,0.12);
  text-decoration: underline;
}
.source-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ms-muted);
}
.ask-answer-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin: -2px 0 8px;
}
.speak-btn,
.speak-style-btn {
  border: 1px solid var(--ms-line-strong);
  background: #fff;
  color: var(--ms-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.3;
}
.speak-style-btn {
  color: var(--ms-muted);
  font-weight: 550;
}
.speak-btn:hover,
.speak-style-btn:hover {
  border-color: rgba(0,113,227,0.4);
  background: rgba(0,113,227,0.08);
  color: var(--ms-blue);
}
.speak-btn.speaking {
  border-color: rgba(0,113,227,0.55);
  background: rgba(0,113,227,0.12);
}
.composer {
  border-top: 1px solid var(--ms-line);
  padding-top: 12px;
  margin-top: auto;
  flex-shrink: 0;
}
.composer-box {
  border: 1px solid var(--ms-line-strong);
  background: #f7f9fc;
  border-radius: 16px;
  padding: 10px 12px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.composer-box:focus-within {
  border-color: rgba(0,113,227,0.55);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.1);
  background: #fff;
}
.composer-input {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 4px 2px 8px !important;
  min-height: 52px;
  max-height: 140px;
  resize: none;
  line-height: 1.45;
  overflow-y: hidden;
  width: 100%;
  display: block;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
}
.composer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--ms-line-strong);
  background: #fff;
  color: var(--ms-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.icon-btn:hover {
  color: var(--ms-blue);
  border-color: rgba(0,113,227,0.4);
  background: rgba(0,113,227,0.08);
}
.icon-btn.listening {
  color: #fff;
  background: #ff453a;
  border-color: transparent;
  box-shadow: 0 0 0 4px rgba(255,69,58,0.18);
  animation: voice-pulse 1.2s ease infinite;
}
@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255,69,58,0.16); }
  50% { box-shadow: 0 0 0 7px rgba(255,69,58,0.08); }
}
.send-btn {
  min-width: 88px;
  height: 40px;
  padding: 0 18px;
  border-radius: 12px;
}
.composer-hint { margin-top: 8px; font-size: 12px; color: var(--ms-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: center; }
.chip {
  border: 1px solid var(--ms-line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ms-ink-2);
}
.chip:hover {
  border-color: rgba(0,113,227,0.4);
  color: var(--ms-blue);
}
.cite-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--ms-line);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ms-muted);
}
.cite-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.cite-head strong {
  font-size: 12px;
  color: var(--ms-blue);
}
.cite-list { display: grid; gap: 6px; }
.cite-row {
  display: block;
  border: 1px solid var(--ms-line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfcfe;
}
.cite-row.flash,
.cite-hit.flash {
  border-color: var(--ms-blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.2);
  animation: cite-flash 1.6s ease;
}
@keyframes cite-flash {
  0% { background: rgba(0,113,227,0.12); }
  100% { background: #fbfcfe; }
}
.cite-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.cite-card-head h4 {
  margin: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  min-width: 0;
  color: var(--ms-ink);
}
.cite-fname {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cite-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ms-blue);
  color: #fff;
  font-size: 10px;
  flex-shrink: 0;
}
.cite-score { font-size: 11px; color: var(--ms-muted); white-space: nowrap; }
.cite-row .src { font-size: 11px; color: var(--ms-muted); margin-top: 2px; }
.cite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.cite-act {
  border: 1px solid var(--ms-line-strong);
  background: #fff;
  color: var(--ms-blue);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.cite-act:hover {
  border-color: rgba(0,113,227,0.45);
  background: rgba(0,113,227,0.08);
}
.cite-hits { margin-top: 8px; display: grid; gap: 6px; }
.cite-hits.hidden { display: none; }
.cite-hit {
  border: 1px solid var(--ms-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f5f7fb;
}
.cite-hit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--ms-muted);
}
.cite-hit-no { color: var(--ms-blue); font-weight: 700; }
.cite-hit-body {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ms-muted);
}
.cite-hit-actions { margin-top: 6px; display: flex; gap: 6px; }
.cite-empty {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f5f7fb;
  font-size: 12px;
}
.ms-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(420px, 90vw);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(22, 28, 36, 0.92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--ms-shadow);
}
.ms-toast.hidden { display: none; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 24, 28, 0.78);
  display: grid;
  place-items: center;
  padding: 56px 24px 28px;
  backdrop-filter: blur(6px);
}
.lightbox.hidden { display: none; }
.lightbox-stage {
  display: grid;
  gap: 10px;
  justify-items: center;
  max-width: min(960px, 100%);
  width: 100%;
}
.lightbox img {
  width: auto;
  max-width: 100%;
  max-height: min(78vh, 100%);
  border-radius: 12px;
  box-shadow: var(--ms-shadow);
  object-fit: contain;
  background: #fff;
}
.lightbox-caption {
  color: #fff;
  text-align: center;
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.lightbox-caption strong { font-size: 14px; }
.lightbox-caption span { opacity: 0.8; font-size: 12px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #222;
  cursor: pointer;
  line-height: 22px;
  font-size: 20px;
}
.doc-viewer {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(16, 22, 30, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}
.doc-viewer.hidden { display: none; }
.doc-viewer-panel {
  width: min(960px, 100%);
  height: min(88vh, 920px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--ms-shadow);
}
.doc-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ms-line);
}
.doc-viewer-eyebrow {
  margin: 0;
  font-size: 11px;
  color: var(--ms-muted);
}
.doc-viewer-head strong {
  display: block;
  font-size: 15px;
  margin-top: 2px;
}
.doc-viewer-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f3f5f8;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.doc-viewer-close:hover {
  background: rgba(0,113,227,0.12);
  color: var(--ms-blue);
}
.doc-viewer-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #f4f6f9;
}
.doc-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.doc-viewer-text {
  margin: 0;
  padding: 18px 22px;
  height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "Songti SC", "SimSun", "宋体", serif;
  font-size: 15px;
  line-height: 1.75;
  color: #222;
  background: #fff;
}
.doc-viewer-loading,
.doc-viewer-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--ms-muted);
  font-size: 14px;
}
.doc-viewer-error { color: #c41e3a; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: var(--ms-shadow-sm);
  backdrop-filter: blur(10px);
}
.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.list-card {
  border: 1px solid var(--ms-line);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s var(--ease);
}
.list-card:hover {
  border-color: rgba(0,113,227,0.35);
  transform: translateY(-1px);
  box-shadow: var(--ms-shadow-sm);
}
.list-card.active {
  border-color: rgba(0,113,227,0.45);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.1);
}
.list-card .t { font-weight: 620; font-size: 14px; letter-spacing: -0.01em; }
.list-card .d { font-size: 12px; color: var(--ms-muted); margin-top: 4px; }
.editor {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--ms-line-strong);
  border-radius: 14px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  background: #fbfcfe;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.switch input { accent-color: var(--ms-blue); }
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ms-muted);
  font-size: 14px;
}
.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}
.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ms-muted);
  animation: blink 1.2s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .split-2 { grid-template-columns: 1fr; }
  .ask-shell {
    grid-template-columns: 1fr;
    height: calc(100vh - 100px);
  }
  .history-toggle { display: inline-flex; }
  .history-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 45;
    transform: translateX(-105%);
    transition: transform .22s ease;
    border-radius: 0 var(--ms-radius) var(--ms-radius) 0;
  }
  .history-panel.open { transform: translateX(0); }
  .history-scrim:not(.hidden) { display: block; }
  .topbar { padding: 20px 18px 10px; }
  .view-host { padding: 8px 18px 24px; }
  body.ask-focused .view-host { padding: 4px 10px 10px; }
}
