:root {
  color-scheme: light;
  --app-height: 100dvh;
  --canvas: #f4f5f2;
  --paper: #ffffff;
  --sidebar: #eef0ed;
  --sidebar-hover: #e5e8e4;
  --ink: #18243a;
  --muted: #68707d;
  --quiet: #9298a1;
  --line: #dde0dc;
  --line-strong: #ccd1cc;
  --navy: #264c7d;
  --navy-soft: #e9eef6;
  --orange: #d98a2b;
  --orange-soft: #fbf0df;
  --green: #36705d;
  --green-soft: #e7f1ed;
  --purple: #705c82;
  --danger: #9a4b45;
  --shadow: 0 18px 54px rgba(30, 42, 57, 0.12);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

button, a, select, input, textarea { outline: none; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(38, 76, 125, 0.18);
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 0;
  height: var(--app-height);
  transition: grid-template-columns 180ms ease;
}

.app-shell.source-open { grid-template-columns: 256px minmax(0, 1fr) 390px; }

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand-block {
  display: flex;
  align-items: center;
  min-height: 74px;
  padding: 14px 14px 12px;
  gap: 11px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid rgba(31, 53, 83, 0.12);
  border-radius: 50%;
  background: #fff;
}

.brand-copy { display: grid; min-width: 0; gap: 2px; }
.brand-copy strong { font-size: 14px; letter-spacing: 0.01em; }
.brand-copy span { color: var(--muted); font-size: 10.5px; letter-spacing: 0.04em; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(24, 36, 58, 0.06); }
.sidebar-close { display: none; margin-left: auto; }

.primary-nav { padding: 5px 10px 12px; }
.nav-item, .recent-item, .sidebar-utility {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav-item {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin: 2px 0;
  padding: 0 11px;
  border-radius: 9px;
  gap: 10px;
  font-weight: 600;
}
.nav-item:hover, .recent-item:hover, .sidebar-utility:hover { background: var(--sidebar-hover); }
.nav-item.active { background: var(--paper); box-shadow: inset 0 0 0 1px rgba(24, 36, 58, 0.05); }
.nav-icon, .utility-icon { display: inline-flex; width: 19px; height: 19px; color: var(--muted); }
.nav-item.active .nav-icon { color: var(--navy); }
.nav-item .nav-badge {
  min-width: 20px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(24,36,58,.06);
  font-size: 11px;
  text-align: center;
}

.recent-section {
  min-height: 0;
  flex: 1;
  padding: 10px 10px 0;
  border-top: 1px solid rgba(24, 36, 58, 0.06);
  overflow: hidden;
}
.section-label {
  padding: 0 11px 8px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.recent-list { overflow-y: auto; max-height: calc(100dvh - 310px); }
.recent-item {
  display: block;
  padding: 8px 11px;
  border-radius: 8px;
  color: #4c5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty-recent { padding: 7px 11px; color: var(--quiet); font-size: 12px; line-height: 1.7; }

.sidebar-footer { padding: 10px; }
.sidebar-utility {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 8px;
  gap: 9px;
  color: var(--muted);
}


.main-area { min-width: 0; display: flex; flex-direction: column; background: var(--paper); }
.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
}
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; }
.breadcrumb .muted { color: var(--muted); }
.breadcrumb strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-menu { display: none; }

.foundation-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  cursor: pointer;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.foundation-pill:hover { border-color: var(--line-strong); background: var(--canvas); }
.foundation-mark {
  display: inline-grid;
  place-items: center;
  height: 23px;
  padding: 0 6px;
  border-radius: 5px;
  color: #fff;
  background: var(--ink);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
}
.role-picker {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  gap: 8px;
  color: var(--quiet);
  font-size: 11px;
}
.role-picker select {
  max-width: 108px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
}

.view-root { min-height: 0; flex: 1; overflow: auto; background: var(--paper); }

.chat-view { height: calc(var(--app-height) - 60px); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-scroll {
  min-height: 0;
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 42px 42px 30px;
  overflow-y: auto;
}
.welcome { padding-top: clamp(18px, 8vh, 74px); }
.welcome-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 20px;
  border-radius: 14px 14px 14px 5px;
  color: #fff;
  background: var(--navy);
  box-shadow: 10px 10px 0 var(--orange-soft);
}
.welcome h1 {
  max-width: 660px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.035em;
}
.welcome > p { max-width: 620px; margin: 16px 0 26px; color: var(--muted); font-size: 15px; line-height: 1.75; }
.knowledge-scope { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.scope-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  gap: 7px;
  color: var(--muted);
}
.scope-chip:hover { border-color: #b8c1ca; }
.scope-chip.active { border-color: rgba(38,76,125,.32); color: var(--navy); background: var(--navy-soft); }
.scope-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.suggestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 700px; }
.suggestion-card {
  min-height: 82px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition: border-color 140ms ease, transform 140ms ease;
}
.suggestion-card:hover { border-color: #aeb8c3; transform: translateY(-1px); }
.suggestion-card strong { display: block; margin-bottom: 5px; font-size: 13px; }
.suggestion-card span { color: var(--muted); font-size: 12px; line-height: 1.5; }

.message-list { display: grid; gap: 28px; }
.message-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; }
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--navy);
  font-weight: 750;
  font-size: 11px;
}
.avatar.user { color: #fff; border-color: var(--ink); background: var(--ink); }
.message-body { min-width: 0; padding-top: 3px; }
.message-meta { margin-bottom: 8px; color: var(--quiet); font-size: 11px; }
.message-content { max-width: 720px; font-size: 15px; line-height: 1.82; }
.message-content strong { color: #102f56; font-weight: 700; }
.user-bubble { display: inline-block; padding: 10px 14px; border-radius: 13px 13px 4px 13px; background: var(--canvas); }
.trace-strip {
  display: flex;
  align-items: center;
  max-width: 700px;
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: #fafbfa;
  font-size: 11px;
  gap: 5px;
}
.trace-step { display: inline-flex; align-items: center; gap: 5px; }
.trace-step + .trace-step::before { content: ''; width: 18px; height: 1px; margin-right: 3px; background: var(--line-strong); }
.trace-check { color: var(--green); }
.thinking-dots { display: inline-flex; gap: 4px; padding: 10px 0; }
.thinking-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); animation: pulse 1s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: 120ms; }
.thinking-dots i:nth-child(3) { animation-delay: 240ms; }
@keyframes pulse { 0%,100%{opacity:.25;transform:translateY(0)} 50%{opacity:1;transform:translateY(-3px)} }

.citation-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.citation-button {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid #ccd5df;
  border-radius: 8px;
  color: var(--navy);
  background: #f7f9fc;
  cursor: pointer;
  gap: 6px;
  font-size: 11px;
}
.citation-button:hover { border-color: #98a9bc; background: var(--navy-soft); }
.citation-index { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 5px; color: #fff; background: var(--navy); font-size: 9px; }
.message-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.text-action {
  min-height: 29px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}
.text-action:hover { background: var(--canvas); color: var(--ink); }
.follow-up { border: 1px solid var(--line); background: #fff; }

.composer-wrap {
  flex: 0 0 auto;
  width: 100%;
  padding: 12px 28px 22px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 22%, #fff);
}
.composer {
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 34px rgba(23,36,58,.09);
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 55px;
  max-height: 150px;
  resize: none;
  padding: 15px 16px 6px;
  border: 0;
  background: transparent;
  line-height: 1.5;
}
.composer textarea::placeholder { color: #9ca1a9; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px 11px; }
.composer-scope { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font-size: 11px; }
.composer-scope span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-send {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
}
.composer-send:disabled { background: #c5c9ce; cursor: default; }
.composer-note { max-width: 800px; margin: 7px auto 0; color: var(--quiet); font-size: 10px; text-align: center; }

.page { max-width: 1160px; margin: 0 auto; padding: 40px 42px 64px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-heading h1 { margin: 0 0 8px; font-family: var(--serif); font-size: 32px; line-height: 1.2; font-weight: 600; letter-spacing: -.025em; }
.page-heading p { max-width: 650px; margin: 0; color: var(--muted); line-height: 1.7; }
.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  cursor: pointer;
  gap: 8px;
  font-weight: 650;
  font-size: 12px;
}
.primary-button { border: 1px solid var(--ink); color: #fff; background: var(--ink); }
.primary-button:hover { background: #25344e; }
.secondary-button { border: 1px solid var(--line-strong); background: #fff; }
.secondary-button:hover { background: var(--canvas); }
.danger-button { border: 1px solid #c98e88; color: var(--danger); background: #fff; }
.button-icon { display: inline-flex; width: 16px; height: 16px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.search-box { position: relative; flex: 1; max-width: 430px; }
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 13px 0 37px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.search-icon { position: absolute; left: 12px; top: 10px; width: 17px; height: 17px; color: var(--quiet); }
.select-filter { height: 38px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--muted); }

.kb-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.kb-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  min-height: 156px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  gap: 15px;
  overflow: hidden;
}
.kb-card::after { content:''; position:absolute; inset:auto 0 0; height:3px; background:var(--kb-color); opacity:.8; transform:scaleX(.22); transform-origin:left; transition:transform 160ms ease; }
.kb-card:hover { border-color: #b9c0c7; }
.kb-card:hover::after { transform: scaleX(1); }
.kb-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; color: var(--kb-color); background: color-mix(in srgb, var(--kb-color) 10%, white); }
.kb-copy { min-width: 0; }
.kb-copy h2 { margin: 2px 0 6px; font-size: 15px; }
.kb-copy p { min-height: 38px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.kb-meta { display: flex; align-items: center; gap: 9px; margin-top: 16px; color: var(--quiet); font-size: 10.5px; }
.kb-meta strong { color: var(--ink); font-size: 13px; }

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--kb-color);
  border-radius: 14px;
  background: linear-gradient(110deg, color-mix(in srgb, var(--kb-color) 5%, white), white 55%);
  gap: 20px;
}
.detail-hero h1 { margin: 0 0 7px; font-family: var(--serif); font-size: 28px; font-weight: 600; }
.detail-hero p { margin: 0; color: var(--muted); line-height: 1.6; }
.detail-stats { display: flex; gap: 18px; }
.detail-stat { display: grid; gap: 2px; min-width: 64px; }
.detail-stat strong { font-size: 20px; }
.detail-stat span { color: var(--quiet); font-size: 10px; }
.detail-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }

.document-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.document-row {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) 100px 120px 100px 34px;
  align-items: center;
  min-height: 68px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
  cursor: pointer;
}
.document-row:last-child { border-bottom: 0; }
.document-row:hover { background: #fafbfa; }
.document-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.doc-glyph { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 38px; border: 1px solid var(--line); border-radius: 7px; color: var(--navy); background: var(--navy-soft); font-size: 9px; font-weight: 750; }
.document-title div { min-width: 0; }
.document-title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.document-title span { color: var(--quiet); font-size: 10px; }
.table-cell { color: var(--muted); font-size: 11px; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; color: var(--green); font-size: 11px; }
.status-chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.row-arrow { color: var(--quiet); }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state .empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; color: var(--navy); background: var(--navy-soft); }
.empty-state h3 { margin: 0 0 7px; color: var(--ink); }
.empty-state p { margin: 0 auto 18px; max-width: 440px; line-height: 1.7; }

.source-panel {
  min-width: 0;
  border-left: 0;
  background: #fbfbfa;
  overflow: hidden;
  visibility: hidden;
}
.source-open .source-panel { visibility: visible; border-left: 1px solid var(--line); }
.source-inner { height: 100%; display: flex; flex-direction: column; }
.source-header { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 15px 0 18px; border-bottom: 1px solid var(--line); }
.source-header strong { font-size: 13px; }
.source-body { flex: 1; overflow: auto; padding: 22px 20px 60px; }
.source-type { display: inline-flex; padding: 3px 7px; border-radius: 5px; color: var(--navy); background: var(--navy-soft); font-size: 9px; font-weight: 700; }
.source-body h2 { margin: 10px 0 8px; font-family: var(--serif); font-size: 23px; line-height: 1.35; font-weight: 600; }
.source-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--quiet); font-size: 10.5px; }
.source-section { padding: 20px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 10px; }
.source-section:last-child { border-bottom: 0; }
.source-section h3 { margin: 0 0 10px; font-size: 13px; }
.source-section p { margin: 0; color: #4f5865; font-size: 13px; line-height: 1.85; }
.source-section.highlight { margin: 8px -10px; padding: 17px 10px; border: 1px solid #dfc498; border-radius: 9px; background: #fff9ee; }
.source-note { margin-top: 18px; padding: 12px; border-left: 3px solid var(--orange); color: var(--muted); background: var(--orange-soft); font-size: 11px; line-height: 1.65; }

.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(21,29,41,.42); backdrop-filter: blur(3px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px 20px; }
.modal-body p { margin: 0 0 14px; color: var(--muted); line-height: 1.7; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 7px; margin: 14px 0; }
.field label { font-size: 11px; font-weight: 650; }
.field input { height: 40px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; }
.import-file { display: flex; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 10px; gap: 11px; background: var(--canvas); }
.import-file .doc-glyph { background: #fff; }
.import-file strong { display: block; font-size: 12px; }
.import-file span { color: var(--quiet); font-size: 10px; }
.progress-list { display: grid; gap: 11px; margin-top: 20px; }
.progress-step { display: flex; align-items: center; gap: 10px; color: var(--quiet); font-size: 12px; }
.progress-dot { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line); border-radius: 50%; font-size: 9px; }
.progress-step.done { color: var(--green); }
.progress-step.active { color: var(--ink); font-weight: 650; }
.progress-step.active .progress-dot { border-color: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.vif-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 15px; }
.vif-card { padding: 11px; border: 1px solid var(--line); border-radius: 9px; }
.vif-card strong { display: block; margin-bottom: 4px; font-size: 11px; }
.vif-card span { color: var(--muted); font-size: 10px; line-height: 1.5; }

.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 360px; padding: 11px 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; color: #fff; background: #253248; box-shadow: 0 10px 30px rgba(20,30,44,.22); font-size: 12px; animation: toast-in 170ms ease-out; }
@keyframes toast-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.sidebar-backdrop { display: none; }
.mobile-only { display: none; }

@media (max-width: 1100px) {
  .app-shell.source-open { grid-template-columns: 256px minmax(0, 1fr); }
  .source-panel { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(410px, 92vw); box-shadow: -20px 0 55px rgba(24,36,58,.16); transform: translateX(100%); transition: transform 180ms ease; }
  .source-open .source-panel { transform: translateX(0); }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .app-shell, .app-shell.source-open { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(286px, 86vw); transform: translateX(-102%); transition: transform 180ms ease; box-shadow: 18px 0 45px rgba(24,36,58,.18); }
  .sidebar-visible .sidebar { transform: translateX(0); }
  .sidebar-close, .mobile-menu { display: inline-grid; }
  .sidebar-visible .sidebar-backdrop { display: block; position: fixed; z-index: 19; inset: 0; background: rgba(24,36,58,.3); }
  .main-area { height: var(--app-height); }
  .chat-view { height: calc(var(--app-height) - 56px); }
  .topbar { min-height: 56px; padding: 0 12px; }
  .topbar-actions { gap: 6px; }
  .foundation-pill { display: none; }
  .role-picker { height: 32px; padding-left: 7px; }
  .role-picker > span { display: none; }
  .chat-scroll { padding: 26px 18px 20px; }
  .welcome { padding-top: 22px; }
  .welcome h1 { font-size: 31px; }
  .welcome > p { margin-top: 13px; font-size: 14px; }
  .knowledge-scope { flex-wrap: nowrap; margin-right: -18px; padding-right: 18px; overflow-x: auto; }
  .scope-chip { flex: 0 0 auto; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .suggestion-card { min-height: 68px; }
  .message-row { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; }
  .avatar { width: 27px; height: 27px; border-radius: 8px; }
  .message-content { font-size: 14px; }
  .trace-strip { overflow-x: auto; white-space: nowrap; }
  .composer-wrap { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .composer { border-radius: 14px; }
  .composer-note { display: none; }
  .page { padding: 26px 16px 50px; }
  .page-heading { display: block; margin-bottom: 20px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading .primary-button { margin-top: 16px; }
  .kb-grid { grid-template-columns: 1fr; }
  .kb-card { min-height: 132px; padding: 17px; }
  .detail-hero { grid-template-columns: 1fr; padding: 18px; }
  .detail-stats { justify-content: flex-start; }
  .detail-actions { align-items: stretch; flex-direction: column; }
  .detail-actions .toolbar { margin: 0; }
  .document-table { border: 0; overflow: visible; }
  .document-row { grid-template-columns: minmax(0, 1fr) 24px; min-height: 76px; margin-bottom: 8px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; }
  .document-row:last-child { border-bottom: 1px solid var(--line); }
  .table-cell, .document-row > .status-chip { display: none; }
  .source-panel { width: 100vw; }
  .source-body { padding: 20px 17px 48px; }
  .vif-grid { grid-template-columns: 1fr; }
  .mobile-only { display: block; }
}

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

.account-trigger { display:flex; align-items:center; gap:10px; width:100%; padding:12px 9px; margin-top:8px; border-top:1px solid var(--line); border-radius:9px; text-align:left; }
.account-trigger:hover { background:rgba(24,36,58,.06); }
.account-avatar { width:36px; height:36px; flex-shrink:0; display:grid; place-items:center; border-radius:50%; background:#0db65b; color:white; font-weight:650; }
.account-copy { display:grid; gap:3px; flex:1; }
.account-copy strong { font-size:14px; font-weight:600; }
.account-copy small { font-size:11px; color:var(--muted); }
.account-menu { position:fixed; inset:auto; margin:0; width:290px; max-width:calc(100vw - 24px); max-height:calc(100dvh - 100px); overflow-y:auto; padding:0; border:1px solid var(--line); border-radius:12px; background:white; color:var(--ink); box-shadow:0 12px 48px #18243a24; }
.account-menu::backdrop { background:transparent; }
.account-identity { display:flex; gap:12px; align-items:center; padding:17px 18px; }
.account-identity strong { font-size:17px; }
.account-identity small { display:block; color:var(--muted); font-size:12px; margin-top:3px; }
.account-group { padding:7px; border-top:1px solid var(--line); }
.account-menu button, .account-menu a { display:flex; align-items:center; gap:12px; width:100%; padding:10px 12px; text-align:left; border-radius:7px; font-size:14px; text-decoration:none; color:inherit; }
.account-menu button:hover, .account-menu a:hover { background:#f3f5f7; }
.account-menu .button-icon { width:19px; height:19px; color:#74777a; flex-shrink:0; }
.account-menu .account-exit { color:#e14d5b; }
.account-workspace small { display:block; color:var(--muted); font-size:12px; margin-top:4px; }
.account-trigger, .account-menu button { border:0; background:transparent; font-family:inherit; cursor:pointer; }
.account-trigger { border-top:1px solid var(--line); }
.account-menu button:focus-visible, .account-trigger:focus-visible, .account-menu a:focus-visible { outline:2px solid #315a91; outline-offset:-2px; }
