:root {
  color-scheme: light;
  --bg: #fafafa;
  --bg-2: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --text: #3d4852;
  --muted: #64748b;
  --faint: #94a3b8;
  --accent: #0052ff;
  --accent-light: #4d7cff;
  --accent-ink: #ffffff;
  --cyan: #0ea5e9;
  --green: #14b8a6;
  --amber: #d97706;
  --red: #dc2626;
  --soft: rgba(0, 82, 255, 0.06);
  --soft-line: rgba(0, 82, 255, 0.22);
  --shadow: 0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 20px 25px rgba(15, 23, 42, 0.11), 0 8px 24px rgba(0, 82, 255, 0.12);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-accent: 0 8px 24px rgba(0, 82, 255, 0.26);
  --radius: 12px;
  --radius-sm: 12px;
  --radius-lg: 18px;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Calistoga", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 14% 8%, rgba(0, 82, 255, 0.08), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(77, 124, 255, 0.07), transparent 28%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.main {
  min-width: 0;
  flex: 1;
  overflow: auto;
  position: relative;
}

.sidebar {
  width: 252px;
  flex: 0 0 252px;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 1px var(--soft-line), 0 6px 24px rgba(198, 242, 78, 0.16);
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-sub,
.side-user em {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.side-nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 9px 10px;
  border-radius: var(--radius);
  text-align: left;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.sel {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.disabled {
  color: var(--faint);
}

.nav-item span {
  flex: 1;
}

.nav-count {
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.side-section {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 22px 10px 8px;
  text-transform: uppercase;
}

.side-agents {
  display: grid;
  gap: 5px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.side-agent {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  min-width: 0;
  width: 100%;
  padding: 5px 8px;
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
}

.side-agent:hover,
.side-agent.sel {
  background: var(--surface);
  color: var(--text);
}

.side-agent span:last-child {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-empty {
  color: var(--faint);
  padding: 8px 10px;
}

.side-foot {
  margin-top: auto;
  padding-top: 18px;
  display: grid;
  gap: 12px;
}

.side-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(61, 214, 140, 0.14);
}

.side-user {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.user-av {
  width: 31px;
  height: 31px;
  border-radius: var(--radius);
  background: var(--surface-3);
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.side-user b {
  display: block;
  font-size: 13px;
}

.toast {
  position: sticky;
  top: 14px;
  z-index: 20;
  margin: 14px auto 0;
  max-width: 1180px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.toast.error {
  color: #ffd4d3;
  border-color: rgba(239, 100, 97, 0.45);
  background: rgba(239, 100, 97, 0.11);
}

.library,
.detail,
.create-view,
.chat-view {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 36px 40px;
}

.chat-view {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.sub {
  color: var(--muted);
  margin-top: 4px;
}

.lib-head,
.create-head,
.detail-head,
.kn-head,
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.lib-head {
  align-items: flex-end;
  margin-bottom: 22px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.metric,
.ov-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
}

.metric b,
.ov-stat b {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.metric em,
.ov-stat em {
  display: block;
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
  margin-top: 4px;
}

.ov-stat small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 7px;
}

.lib-toolbar {
  margin-bottom: 20px;
}

.search {
  max-width: 330px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 13px;
  color: var(--faint);
}

.search input,
.chat-input input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  width: 100%;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.agent-card {
  min-height: 206px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.agent-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.new-card {
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--faint);
  border-style: dashed;
  background: transparent;
}

.new-card:hover {
  color: var(--accent);
  border-color: var(--soft-line);
  transform: none;
}

.new-card-plus {
  width: 44px;
  height: 44px;
  border: 1px solid currentColor;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.ac-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 13px;
}

.ac-del {
  opacity: 0;
}

.agent-card:hover .ac-del {
  opacity: 1;
}

.ac-name {
  font-size: 16px;
  font-weight: 700;
}

.ac-desc {
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 4px 0 14px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ac-sources {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}

.ac-more {
  color: var(--faint);
  font-size: 12px;
}

.ac-foot {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 13px;
}

.ac-stat {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.ac-model {
  margin-left: auto;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 7px;
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 14px;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
  white-space: nowrap;
}

.btn-sm {
  min-height: 31px;
  padding: 5px 10px;
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  box-shadow: 0 0 0 4px var(--soft), 0 8px 24px rgba(198, 242, 78, 0.14);
  transform: translateY(-1px);
}

.btn-ghost,
.btn-soft {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.48);
  color: var(--red);
}

.btn-ghost:hover,
.btn-soft:hover {
  background: var(--surface-2);
  border-color: var(--line-2);
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.13);
  border-color: var(--red);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--faint);
  display: grid;
  place-items: center;
  transition: background 140ms ease, color 140ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.glyph {
  flex: 0 0 auto;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--accent);
  display: grid;
  font-weight: 800;
  place-items: center;
}

.type-chip {
  border: 1px solid rgba(90, 209, 214, 0.28);
  border-radius: 7px;
  background: rgba(90, 209, 214, 0.12);
  color: var(--cyan);
  display: grid;
  flex: 0 0 auto;
  place-items: center;
}

.type-chip.good {
  border-color: rgba(61, 214, 140, 0.28);
  background: rgba(61, 214, 140, 0.12);
  color: var(--green);
}

.type-chip.wait {
  border-color: rgba(246, 196, 83, 0.28);
  background: rgba(246, 196, 83, 0.12);
  color: var(--amber);
}

.type-chip.bad {
  border-color: rgba(239, 100, 97, 0.28);
  background: rgba(239, 100, 97, 0.12);
  color: var(--red);
}

.mini-chip {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 8px;
}

.empty {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 7px;
  padding: 34px 16px;
  text-align: center;
}

.empty-ico {
  width: 56px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--faint);
  display: grid;
  place-items: center;
  margin-bottom: 7px;
}

.empty-title {
  font-weight: 800;
  font-size: 16px;
}

.empty-sub {
  max-width: 340px;
  color: var(--muted);
}

.create-view {
  display: flex;
  flex-direction: column;
}

.create-head {
  padding-bottom: 26px;
}

.back-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
}

.back-btn:hover {
  color: var(--text);
}

.step-rail {
  display: flex;
  align-items: center;
  gap: 4px;
}

.step-node {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-dot {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--faint);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.step-node.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px var(--soft);
}

.step-node.done .step-dot {
  border-color: var(--soft-line);
  color: var(--accent);
}

.step-text {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: capitalize;
}

.step-text em {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
}

.step-node.active .step-text {
  color: var(--text);
}

.step-line {
  width: 36px;
  height: 1px;
  background: var(--line);
  margin: 0 8px;
}

.step-line.done {
  background: var(--soft-line);
}

.create-body {
  flex: 1;
}

.configure-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 28px;
  align-items: start;
  max-width: 1000px;
  margin: 0 auto;
}

.cfg-main,
.cfg-side,
.settings-tab,
.knowledge-tab {
  display: grid;
  gap: 16px;
}

.cfg-side {
  position: sticky;
  top: 20px;
}

.section-label {
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 36px 22px;
  text-align: center;
}

.file-drop {
  cursor: pointer;
  min-height: 292px;
  position: relative;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.file-drop:hover,
.file-drop:focus-within {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.file-drop.has-file {
  border-color: var(--accent);
}

.file-input {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.dropzone-ico {
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--accent);
  display: grid;
  place-items: center;
}

.dropzone-title {
  font-size: 17px;
  font-weight: 800;
}

.dropzone-sub {
  color: var(--muted);
  max-width: 520px;
}

.clear-source {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  margin-top: 10px;
  padding: 7px 10px;
}

.clear-source:hover {
  border-color: var(--line-2);
  color: var(--text);
}

.dropzone-types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.dropzone-action {
  align-items: center;
  background: var(--accent);
  border-radius: var(--radius-sm);
  color: #11160c;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
  margin-top: 14px;
  min-height: 36px;
  padding: 0 16px;
}

.file-drop:hover .dropzone-action,
.file-drop:focus-within .dropzone-action {
  box-shadow: 0 0 0 4px rgba(190, 255, 62, 0.13);
}

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  display: flex;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.field-label em {
  color: var(--faint);
  font-style: normal;
  font-weight: 500;
}

.text-input,
.text-area,
select.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 10px 13px;
  outline: 0;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.text-input.lg {
  font-size: 16px;
  font-weight: 800;
}

.text-area {
  min-height: 112px;
  line-height: 1.55;
  resize: vertical;
}

.text-area.tall {
  min-height: 176px;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--soft-line);
  box-shadow: 0 0 0 4px var(--soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

.side-card,
.kb-summary,
.knowledge-upload,
.ov-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.glyph-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.glyph-opt {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.glyph-opt:hover,
.glyph-opt.sel {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--soft);
}

.model-list {
  display: grid;
  gap: 8px;
}

.graph-mode-list {
  display: grid;
  gap: 8px;
}

.graph-mode-card {
  min-height: 58px;
}

.model-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  text-align: left;
}

.model-card:hover,
.model-card.sel {
  border-color: var(--accent);
  background: var(--soft);
}

.model-radio {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-2);
  border-radius: 999px;
}

.model-card.sel .model-radio {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 38%, transparent 42%);
}

.model-text b,
.model-text em {
  display: block;
}

.model-provider {
  color: var(--accent);
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.model-text em {
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.kb-summary {
  display: grid;
  gap: 10px;
}

.kb-row {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
}

.create-foot {
  position: sticky;
  bottom: 0;
  border-top: 1px solid var(--line);
  background: linear-gradient(transparent, var(--bg) 30%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
  padding: 18px 0;
}

.foot-info {
  color: var(--faint);
  font-size: 12px;
}

.foot-actions {
  display: flex;
  gap: 10px;
}

.detail-head {
  flex-wrap: wrap;
}

.detail-head .back-btn {
  width: 100%;
}

.detail-id {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ready-dot {
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

.ready-dot.wait {
  color: var(--amber);
}

.ready-dot.bad {
  color: var(--red);
}

.tabs {
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  margin-top: 24px;
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: -1px;
  padding: 11px 14px;
  text-transform: capitalize;
}

.tab:hover,
.tab.sel {
  color: var(--text);
}

.tab.sel {
  border-bottom-color: var(--accent);
}

.detail-body {
  padding-top: 26px;
}

.overview {
  display: grid;
  gap: 16px;
}

.ov-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.ov-card-h {
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.instructions {
  color: var(--text);
  line-height: 1.65;
}

.ov-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ov-tool {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
}

.ov-tool svg {
  color: var(--accent);
}

.kb-id {
  color: var(--faint);
  font-size: 11px;
}

.knowledge-upload {
  display: grid;
  grid-template-columns: minmax(190px, 0.55fr) minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.kn-stat {
  color: var(--muted);
}

.kn-stat b {
  color: var(--text);
}

.kn-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.kn-tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 98px 82px 92px 82px 86px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
  padding: 12px 16px;
}

.kn-tr:last-child {
  border-bottom: 0;
}

.kn-thead {
  min-height: 40px;
  background: var(--bg-2);
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.kn-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kn-dim {
  color: var(--muted);
  font-size: 13px;
}

.graph-dim {
  color: var(--accent);
  font-weight: 800;
}

.kn-actions {
  display: flex;
  gap: 4px;
}

.kn-empty {
  color: var(--muted);
  padding: 18px;
}

.status {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 8px;
}

.status.good {
  border-color: rgba(61, 214, 140, 0.32);
  color: var(--green);
}

.status.wait {
  border-color: rgba(246, 196, 83, 0.32);
  color: var(--amber);
}

.status.bad,
.msg.refused .msg-bubble {
  border-color: rgba(239, 100, 97, 0.4);
  color: #ffd4d3;
}

.kn-status-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.kb-stale-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(246, 196, 83, 0.32);
  border-radius: 10px;
  background: rgba(246, 196, 83, 0.08);
  color: var(--amber);
  font-size: 13px;
}

.kb-stale-banner .kb-stale-copy {
  flex: 1;
}

.extractor-tab {
  display: grid;
  gap: 16px;
}

.extractor-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.extractor-head h2 {
  font-size: 22px;
  line-height: 1.2;
}

.extractor-actions {
  display: flex;
  justify-content: flex-end;
}

.extractor-state {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.extractor-preview {
  min-height: 520px;
  max-height: 72vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  margin: 0;
  padding: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.deployments-tab {
  display: grid;
  gap: 18px;
}

.deploy-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.deploy-head h2 {
  font-size: 22px;
  margin: 0 0 6px;
}

.deploy-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 10px;
  min-width: 240px;
}

.secret-panel,
.deploy-create,
.integration-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.secret-panel {
  display: grid;
  gap: 12px;
}

.secret-panel p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.secret-row {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.secret-row code,
.integration-kv code,
.integration-code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
}

.secret-row code {
  overflow: hidden;
  padding: 11px 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deploy-create {
  align-items: end;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.deploy-create-mode {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
}

.seg {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
}

.seg.sel {
  background: var(--surface);
  color: var(--text);
}

.seg:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.deploy-new-fields {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1fr);
  gap: 10px;
}

.deploy-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.deploy-tr {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px minmax(260px, 1.35fr) 120px 120px;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.deploy-tr:last-child {
  border-bottom: 0;
}

.deploy-thead {
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.deploy-app,
.deploy-keys,
.deploy-key,
.deploy-actions {
  display: grid;
  gap: 6px;
}

.deploy-app b {
  font-size: 14px;
}

.deploy-app .mono,
.deploy-key .mono {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.deploy-key {
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-template-columns: minmax(86px, 0.8fr) auto minmax(95px, 1fr) minmax(80px, 0.8fr) auto;
  align-items: center;
  padding: 8px;
}

.deploy-key > span {
  color: var(--muted);
  font-size: 12px;
}

.mini-action {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 8px;
}

.mini-action.danger {
  color: #ffd4d3;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.integration-panel {
  display: grid;
  gap: 12px;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.integration-kv {
  display: grid;
  gap: 6px;
}

.integration-kv span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.integration-kv code {
  min-width: 0;
  overflow: hidden;
  padding: 9px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.integration-code {
  font-size: 12px;
  line-height: 1.6;
  margin: 0;
  overflow: auto;
  padding: 14px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.settings-tab {
  max-width: 700px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.temp-value {
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  color: var(--accent, #ff5a1f);
}

.temp-slider {
  width: 100%;
  accent-color: var(--accent, #ff5a1f);
  margin: 4px 0 2px;
}

.field-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted, #9a9a9a);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.chat-head {
  border-bottom: 1px solid var(--line);
  justify-content: flex-start;
  padding: 18px 4px;
}

.chat-id {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-id b {
  display: block;
  font-size: 15px;
}

.chat-model {
  width: fit-content;
  color: var(--faint);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 3px;
  padding: 3px 7px;
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  margin: 0 -40px;
  padding: 28px 40px;
}

.chat-inner {
  max-width: 750px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  display: flex;
  gap: 12px;
}

.msg.user {
  justify-content: flex-end;
}

.msg-body {
  max-width: 76%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg.user .msg-body {
  align-items: flex-end;
}

.msg-bubble {
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.55;
  padding: 12px 16px;
  white-space: pre-wrap;
}

.msg.assistant .msg-bubble {
  white-space: normal;
}

.msg.assistant .msg-bubble {
  border: 1px solid var(--line);
  background: var(--surface);
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.markdown-answer {
  display: grid;
  gap: 12px;
}

.markdown-answer h3,
.markdown-answer h4 {
  color: var(--text);
  font-size: 16px;
  line-height: 1.35;
  margin: 2px 0 0;
}

.markdown-answer p {
  margin: 0;
}

.markdown-answer ul,
.markdown-answer ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 19px;
}

.markdown-answer li {
  padding-left: 2px;
}

.markdown-answer strong {
  font-weight: 850;
}

.markdown-answer em {
  color: inherit;
  font-style: italic;
}

.markdown-answer code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 1px 5px;
}

.markdown-answer pre {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0d12;
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 12px;
}

.markdown-answer pre code {
  border: 0;
  background: transparent;
  display: block;
  padding: 0;
  white-space: pre;
}

.msg-cites {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.cite-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
}

.cite {
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  padding: 5px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cite-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline citation markers and the per-marker citations panel. */
.cite-ref {
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  vertical-align: super;
  color: var(--accent, #4f7cff);
  cursor: help;
  white-space: nowrap;
}

.markdown-answer .cite-ref {
  margin-left: 1px;
}

.citations-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.citation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  padding: 5px 9px;
}

.citation-item .cite-ref {
  vertical-align: baseline;
  color: var(--accent, #4f7cff);
  flex: 0 0 auto;
}

.citation-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.citation-score {
  margin-left: auto;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
}

.msg-bubble.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
}

.msg-bubble.thinking .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--faint);
  animation: bounce 1100ms infinite;
}

.msg-bubble.thinking .dot:nth-child(2) {
  animation-delay: 140ms;
}

.msg-bubble.thinking .dot:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes bounce {
  0%,
  60%,
  100% {
    opacity: 0.5;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

.chat-input-wrap {
  max-width: 750px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 0 24px;
}

.chat-input {
  min-height: 52px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
}

.chat-input:focus-within {
  border-color: var(--soft-line);
  box-shadow: 0 0 0 4px var(--soft);
}

.send-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
}

.chat-foot {
  color: var(--faint);
  font-size: 11px;
  margin-top: 10px;
  text-align: center;
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface));
  background-size: 240% 100%;
  animation: shimmer 1400ms ease-in-out infinite;
}

.skeleton.wide {
  width: 300px;
  height: 34px;
  margin-bottom: 24px;
}

.skeleton-card {
  cursor: default;
}

.glyph-skel {
  width: 42px;
  height: 42px;
  margin-bottom: 14px;
}

.line {
  height: 14px;
  margin-bottom: 10px;
}

.line.short {
  width: 65%;
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

@media (max-width: 980px) {
  .sidebar {
    display: none;
  }

  .library,
  .detail,
  .create-view,
  .chat-view {
    padding: 24px 18px;
  }

  .configure-grid,
  .knowledge-upload,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .cfg-side {
    position: static;
  }

  .ov-stats,
  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-text {
    display: none;
  }

  .kn-tr {
    grid-template-columns: minmax(0, 1fr) 84px 70px;
  }

  .kn-tr span:nth-child(4),
  .kn-tr span:nth-child(5),
  .kn-tr span:nth-child(6) {
    display: none;
  }

  .detail-actions,
  .lib-head {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-actions .btn,
  .lib-head .btn {
    width: 100%;
  }

  .chat-scroll {
    margin: 0 -18px;
    padding: 24px 18px;
  }

  .msg-body {
    max-width: 88%;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 23px;
  }

  .agent-grid,
  .stats-strip,
  .ov-stats {
    grid-template-columns: 1fr;
  }

  .step-line {
    width: 20px;
    margin: 0 3px;
  }

  .create-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .foot-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Minimalist Modern design-system overrides */
button,
input,
textarea,
select,
a {
  outline: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.file-drop:focus-within {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px var(--bg);
}

.sidebar {
  border-right: 0;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(circle at 10% 0%, rgba(0, 82, 255, 0.2), transparent 34%),
    #0f172a;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(18px);
  color: #f8fafc;
}

.sidebar .brand-name,
.sidebar .side-user b {
  color: #ffffff;
}

.sidebar .brand-sub,
.sidebar .side-section,
.sidebar .side-empty,
.sidebar .nav-count,
.sidebar .side-user em {
  color: rgba(255, 255, 255, 0.58);
}

.sidebar .nav-item,
.sidebar .side-agent,
.sidebar .side-status {
  color: rgba(255, 255, 255, 0.72);
}

.sidebar .nav-item:hover,
.sidebar .side-agent:hover,
.sidebar .side-agent.sel,
.sidebar .nav-item.sel {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar .side-user {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.brand-mark,
.glyph,
.user-av,
.type-chip,
.empty-ico,
.dropzone-ico,
.step-dot,
.new-card-plus {
  border: 1px solid rgba(226, 232, 240, 0.82);
  box-shadow: var(--shadow-sm);
}

.brand-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
}

.brand-name,
.ac-name,
.empty-title,
.dropzone-title,
.detail-id h1,
.lib-head h1 {
  font-family: var(--display);
  font-weight: 400;
}

.lib-head h1,
.detail-id h1 {
  background: linear-gradient(90deg, var(--text), var(--accent) 74%, var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-item,
.side-agent,
.back-btn,
.icon-btn,
.tab,
.glyph-opt,
.model-card,
.btn,
.send-btn,
.clear-source {
  transition: all 200ms ease-out;
}

.nav-item:hover,
.side-agent:hover,
.side-agent.sel,
.nav-item.sel {
  background: var(--soft);
  color: var(--accent);
}

.side-user,
.metric,
.ov-stat,
.agent-card,
.side-card,
.kb-summary,
.knowledge-upload,
.ov-card,
.kn-table,
.msg.assistant .msg-bubble,
.toast {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric b,
.ov-stat b {
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.agent-card,
.metric,
.ov-stat,
.side-card,
.kb-summary,
.knowledge-upload,
.ov-card,
.kn-table {
  padding: 22px;
}

.agent-card:hover,
.metric:hover,
.ov-stat:hover,
.ov-card:hover,
.side-card:hover,
.model-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.new-card {
  border: 1px dashed var(--line-2);
  background: linear-gradient(135deg, #ffffff, rgba(0, 82, 255, 0.035));
  box-shadow: var(--shadow-sm);
}

.new-card:hover {
  color: var(--accent);
  border-color: var(--soft-line);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.section-label {
  width: fit-content;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.15em;
  padding: 7px 12px;
}

.section-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  animation: pulseDot 2s ease-in-out infinite;
}

.ac-foot,
.tabs,
.chat-head,
.create-foot,
.kn-tr {
  border-color: transparent;
}

.ac-model,
.chat-model,
.mini-chip,
.status,
.cite,
.ov-tool,
.dropzone-types span {
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-height: 44px;
}

.btn-primary,
.send-btn,
.dropzone-action {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover,
.btn-ghost:hover,
.btn-soft:hover,
.send-btn:hover,
.dropzone-action:hover {
  box-shadow: var(--shadow-hover);
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.btn-primary svg,
.send-btn svg {
  transition: transform 200ms ease-out;
}

.btn-primary:hover svg,
.send-btn:hover svg {
  transform: translateX(2px);
}

.btn:active,
.send-btn:active,
.icon-btn:active,
.model-card:active,
.glyph-opt:active {
  transform: scale(0.98);
}

.btn-ghost,
.btn-soft,
.icon-btn,
.glyph-opt,
.model-card {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
}

.search,
.chat-input,
.text-input,
.text-area,
select.text-input,
.dropzone {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.dropzone-ico,
.empty-ico {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
}

.text-input:focus,
.text-area:focus,
.chat-input:focus-within,
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px rgba(0, 82, 255, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: #8a94a3;
}

.dropzone {
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 16% 12%, rgba(0, 82, 255, 0.08), transparent 25%),
    var(--surface);
  box-shadow: var(--shadow);
}

.file-drop:hover,
.file-drop:focus-within,
.file-drop.has-file {
  border-color: var(--soft-line);
  background: linear-gradient(135deg, #ffffff, rgba(0, 82, 255, 0.04));
  box-shadow: var(--shadow-hover);
}

.model-card.sel,
.glyph-opt.sel,
.tab.sel {
  background: var(--soft);
  color: var(--accent);
  border-color: var(--soft-line);
  box-shadow: var(--shadow-accent);
}

.model-radio {
  border: 2px solid var(--line-2);
}

.model-card.sel .model-radio {
  background: radial-gradient(circle, var(--accent) 0 38%, transparent 42%);
}

.tab {
  border: 0;
  border-radius: var(--radius);
  min-height: 44px;
  padding: 11px 18px;
}

.tab:hover {
  background: var(--soft);
  box-shadow: var(--shadow-sm);
}

.step-node.active .step-dot {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  box-shadow: var(--shadow-accent);
}

.step-node.done .step-dot {
  color: var(--accent);
  border-color: var(--soft-line);
  background: var(--soft);
}

.step-line {
  height: 2px;
  border-radius: 999px;
  background: var(--line);
}

.step-line.done {
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
}

.type-chip {
  background: var(--surface);
  color: var(--cyan);
}

.type-chip.good {
  background: var(--surface);
  color: var(--green);
}

.type-chip.wait {
  background: var(--surface);
  color: var(--amber);
}

.type-chip.bad,
.status.bad,
.msg.refused .msg-bubble {
  background: var(--surface);
  color: var(--red);
}

.status.good {
  color: var(--green);
}

.status.wait {
  color: var(--amber);
}

.kn-thead {
  background: var(--surface-2);
}

.chat-scroll {
  scrollbar-color: rgba(0, 82, 255, 0.5) transparent;
}

.chat-inner {
  animation: fadeInUp 420ms ease-out both;
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  box-shadow: var(--shadow-accent);
}

.markdown-answer pre {
  border: 1px solid var(--line);
  background: #0f172a;
  color: #f8fafc;
}

.markdown-answer code {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.markdown-answer pre code {
  box-shadow: none;
}

.create-foot {
  background: linear-gradient(transparent, var(--bg) 24%);
}

.spinner {
  border-color: var(--line);
  border-top-color: var(--accent);
}

.skeleton {
  background: linear-gradient(90deg, var(--surface-2), #ffffff, var(--surface-2));
  box-shadow: var(--shadow-sm);
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.62;
    transform: scale(1.3);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 980px) {
  .sidebar {
    margin: 0;
    border-radius: 0;
  }
}

/* Polished alignment pass */
.shell {
  background:
    linear-gradient(180deg, rgba(0, 82, 255, 0.035), transparent 340px),
    var(--bg);
}

.main {
  scroll-behavior: smooth;
}

.library,
.detail,
.create-view,
.chat-view {
  width: min(100%, 1240px);
  max-width: none;
  padding: 40px clamp(24px, 4vw, 56px);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
}

.brand {
  min-height: 58px;
  padding: 4px 8px 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
}

.side-nav {
  gap: 6px;
}

.nav-item,
.side-agent {
  min-height: 42px;
  border-radius: 10px;
}

.side-foot {
  gap: 14px;
}

.lib-head,
.detail-head,
.create-head {
  margin-bottom: 26px;
}

.lib-head {
  align-items: center;
}

.lib-head h1,
.detail-id h1 {
  font-size: clamp(30px, 4vw, 46px);
}

.sub {
  max-width: 620px;
  font-size: 14px;
}

.stats-strip,
.ov-stats {
  gap: 14px;
}

.metric,
.ov-stat {
  min-height: 106px;
  display: grid;
  align-content: space-between;
  padding: 18px;
}

.metric b,
.ov-stat b {
  font-size: 30px;
}

.lib-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.search {
  width: min(100%, 390px);
  max-width: none;
  height: 46px;
}

.agent-grid {
  grid-template-columns: repeat(auto-fill, minmax(292px, 1fr));
  gap: 18px;
  align-items: stretch;
}

.agent-card {
  min-height: 244px;
}

.ac-top {
  min-height: 48px;
  margin-bottom: 16px;
}

.ac-name {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}

.ac-desc {
  min-height: 44px;
}

.ac-sources {
  min-height: 30px;
}

.ac-foot {
  gap: 8px;
  padding-top: 14px;
}

.ac-stat {
  min-width: 0;
}

.ac-model {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  min-height: 42px;
  padding-inline: 16px;
}

.btn svg,
.icon-btn svg,
.send-btn svg {
  flex: 0 0 auto;
}

.configure-grid {
  max-width: 1120px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 32px;
}

.cfg-main,
.cfg-side,
.knowledge-tab,
.settings-tab,
.overview {
  gap: 18px;
}

.dropzone {
  min-height: 286px;
  justify-content: center;
  padding: 34px clamp(20px, 4vw, 44px);
}

.dropzone-title {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 800;
}

.dropzone-sub {
  max-width: 560px;
  line-height: 1.55;
}

.dropzone-action {
  min-height: 38px;
  padding: 0 18px;
}

.side-card,
.kb-summary,
.ov-card,
.knowledge-upload,
.kn-table {
  border-radius: 16px;
}

.glyph-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.glyph-opt {
  width: 100%;
  min-width: 0;
}

.model-card {
  min-height: 70px;
  align-items: center;
}

.model-text {
  min-width: 0;
}

.model-text b,
.model-text em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.create-foot {
  margin-inline: auto;
  width: min(100%, 1120px);
}

.detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.detail-head .back-btn {
  grid-column: 1 / -1;
  width: fit-content;
}

.detail-id {
  min-width: 0;
}

.detail-id h1,
.detail-id .sub {
  overflow-wrap: anywhere;
}

.detail-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ready-dot {
  min-height: 36px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0 12px;
}

.tabs {
  gap: 8px;
  margin-top: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.tab {
  min-width: 112px;
}

.detail-body {
  padding-top: 22px;
}

.knowledge-upload {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  padding: 16px;
}

.kb-health-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.kb-health-grid .ov-stat {
  min-height: 98px;
  padding: 16px;
}

.kb-health-grid .ov-stat:first-child,
.kb-health-grid .ov-stat:nth-child(6) {
  grid-column: span 2;
}

.kb-health-status {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--amber);
  font-weight: 800;
  padding: 16px;
  text-align: center;
}

.kb-health-status.good {
  color: var(--green);
}

.kb-health-status.bad {
  color: var(--red);
}

.knowledge-file-drop {
  min-width: 0;
  min-height: 78px;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  background: linear-gradient(135deg, #ffffff, rgba(0, 82, 255, 0.035));
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.knowledge-file-drop:hover,
.knowledge-file-drop:focus-within,
.knowledge-file-drop.has-file {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.knowledge-file-drop .dropzone-ico {
  width: 48px;
  height: 48px;
}

.knowledge-file-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  flex: 1;
}

.knowledge-file-copy b,
.knowledge-file-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.knowledge-file-copy b {
  font-size: 15px;
  font-weight: 800;
}

.knowledge-file-copy em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.knowledge-file-drop .dropzone-action {
  margin-top: 0;
  flex: 0 0 auto;
}

.knowledge-upload > .clear-source {
  margin: 0;
  min-height: 42px;
}

.knowledge-inventory {
  display: grid;
  gap: 24px;
}

.kb-inventory-section {
  display: grid;
  gap: 16px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-label-row .section-label {
  margin-bottom: 0;
}

.kb-agent-groups,
.kb-orphan-list,
.orphan-chunk-list {
  display: grid;
  gap: 14px;
}

.kb-agent-group,
.kb-orphan-card {
  border: 1px solid var(--line);
  background: var(--surface);
}

.kb-agent-head {
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.kb-agent-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kb-agent-main h2 {
  font-size: 18px;
  line-height: 1.2;
}

.kb-agent-main p {
  color: var(--muted);
  margin-top: 3px;
}

.kb-inventory-list {
  display: grid;
}

.kb-inventory-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, auto) auto;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  min-height: 72px;
  padding: 14px 18px;
}

.kb-inventory-row:last-child {
  border-bottom: 0;
}

.kb-inventory-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.kb-inventory-name > svg {
  color: var(--accent);
  flex: 0 0 auto;
}

.kb-inventory-name span,
.kb-inventory-name b,
.kb-inventory-name em {
  min-width: 0;
}

.kb-inventory-name span {
  display: grid;
  gap: 3px;
}

.kb-inventory-name b,
.kb-inventory-name em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-inventory-name em {
  color: var(--faint);
  font-size: 11px;
  font-style: normal;
}

.kb-inventory-metrics,
.kb-inventory-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.kb-inventory-metrics {
  color: var(--muted);
  font-size: 13px;
}

.kb-inventory-metrics b {
  color: var(--text);
}

.kb-inventory-actions {
  min-width: 112px;
}

.orphan-chunk-card {
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  gap: 12px;
  padding: 16px 18px;
}

.orphan-chunk-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.orphan-chunk-title {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.orphan-chunk-title > svg {
  color: var(--accent);
  flex: 0 0 auto;
  margin-top: 2px;
}

.orphan-chunk-title span,
.orphan-chunk-title b,
.orphan-chunk-title em {
  min-width: 0;
}

.orphan-chunk-title span {
  display: grid;
  gap: 4px;
}

.orphan-chunk-title b,
.orphan-chunk-title em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orphan-chunk-title em {
  color: var(--faint);
  font-size: 11px;
  font-style: normal;
}

.orphan-chunk-card p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

.orphan-chunk-meta,
.orphan-chunk-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.orphan-chunk-meta b {
  color: var(--text);
  font-weight: 700;
}

.orphan-chunk-ids {
  color: var(--faint);
}

.create-ingest-page {
  width: 100%;
}

.source-queue-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.kn-head {
  min-width: 0;
}

.kb-id {
  max-width: min(48vw, 520px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kn-table {
  padding: 0;
}

.kn-tr {
  grid-template-columns: minmax(220px, 1fr) 112px 82px 96px 94px 92px;
  min-height: 64px;
  padding: 14px 18px;
}

.kn-tr.sel {
  background: rgba(0, 82, 255, 0.045);
}

.kn-tr.sel .source-name {
  color: var(--accent);
}

.kn-thead {
  min-height: 46px;
}

.source-name {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-name:hover {
  color: var(--accent);
}

.kn-actions {
  justify-content: flex-end;
}

.status {
  justify-self: start;
  text-transform: capitalize;
}

.chunk-drawer,
.retrieval-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head .section-label {
  margin-bottom: 8px;
}

.panel-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.panel-empty {
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  color: var(--muted);
  display: grid;
  min-height: 120px;
  place-items: center;
  padding: 18px;
  text-align: center;
}

.chunk-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
}

.chunk-card,
.retrieval-match {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
  padding: 13px;
}

.chunk-meta,
.match-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
  margin-bottom: 8px;
}

.chunk-card p,
.retrieval-match p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

.retrieval-panel {
  display: grid;
  gap: 14px;
}

.retrieval-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.retrieval-input input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: 0;
  padding: 0 14px;
}

.retrieval-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px rgba(0, 82, 255, 0.08);
}

.retrieval-results {
  display: grid;
  gap: 10px;
}

.match-top b {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-pill {
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent);
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
}

.settings-tab {
  max-width: 820px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
}

.chat-view {
  width: 100%;
  max-width: none;
  padding-top: 0;
}

.chat-head {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 22px 0;
}

.chat-scroll {
  margin: 0 calc(clamp(24px, 4vw, 56px) * -1);
  padding: 34px clamp(24px, 4vw, 56px);
}

.chat-inner,
.chat-input-wrap {
  max-width: 860px;
}

.msg-body {
  max-width: min(78%, 720px);
}

.msg-bubble {
  border-radius: 18px;
  font-size: 15px;
  padding: 15px 18px;
}

.msg.user .msg-bubble {
  border-bottom-right-radius: 7px;
}

.msg.assistant .msg-bubble {
  border-bottom-left-radius: 7px;
}

.markdown-answer {
  gap: 14px;
}

.markdown-answer h3,
.markdown-answer h4 {
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
}

.chat-input {
  min-height: 60px;
  border-radius: 18px;
  padding-left: 18px;
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

@media (max-width: 1180px) {
  .configure-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 24px;
  }

  .detail-head {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 980px) {
  .library,
  .detail,
  .create-view,
  .chat-view {
    width: 100%;
    padding: 26px 18px;
  }

  .configure-grid,
  .knowledge-upload,
  .kb-workbench,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .kb-health-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kb-health-grid .ov-stat:first-child,
  .kb-health-grid .ov-stat:nth-child(6) {
    grid-column: span 1;
  }

  .knowledge-upload {
    align-items: stretch;
  }

  .knowledge-upload .btn,
  .knowledge-upload > .clear-source {
    width: 100%;
  }

  .knowledge-file-drop {
    align-items: flex-start;
  }

  .knowledge-file-drop .dropzone-action {
    display: none;
  }

  .kb-inventory-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .kb-inventory-metrics,
  .kb-inventory-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .orphan-chunk-top {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }

  .tab {
    flex: 1 0 110px;
  }

  .kn-table {
    overflow-x: auto;
  }

  .kn-tr {
    min-width: 780px;
  }

  .retrieval-input {
    grid-template-columns: 1fr;
  }

  .retrieval-input .btn {
    width: 100%;
  }

  .chat-head,
  .chat-input-wrap {
    width: 100%;
  }

  .chat-scroll {
    margin: 0 -18px;
    padding: 24px 18px;
  }
}

@media (max-width: 640px) {
  .lib-head,
  .detail-id,
  .detail-actions,
  .create-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-id {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .detail-actions .btn,
  .detail-actions .ready-dot,
  .lib-head .btn {
    width: 100%;
    justify-content: center;
  }

  .stats-strip,
  .ov-stats,
  .kb-health-grid,
  .agent-grid {
    grid-template-columns: 1fr;
  }

  .metric,
  .ov-stat {
    min-height: 92px;
    padding: 16px;
  }

  .metric b,
  .ov-stat b {
    font-size: 26px;
  }

  .agent-card {
    min-height: 220px;
  }

  .knowledge-file-drop {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .msg-body {
    max-width: 92%;
  }
}

/* Bold Typography design-system overrides */
:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --bg-2: #0a0a0a;
  --surface: #0f0f0f;
  --surface-2: #1a1a1a;
  --surface-3: #262626;
  --line: #262626;
  --line-2: #404040;
  --text: #fafafa;
  --muted: #a3a3a3;
  --faint: #737373;
  --accent: #ff3d00;
  --accent-light: #ff6a3d;
  --accent-ink: #0a0a0a;
  --cyan: #fafafa;
  --green: #25d366;
  --amber: #f59e0b;
  --red: #ff5a3d;
  --soft: rgba(255, 61, 0, 0.1);
  --soft-line: rgba(255, 61, 0, 0.62);
  --shadow: none;
  --shadow-hover: none;
  --shadow-sm: none;
  --shadow-accent: none;
  --radius: 0;
  --radius-sm: 0;
  --radius-lg: 0;
  --mono: "JetBrains Mono", "Fira Code", monospace;
  --font: "Inter Tight", "Inter", system-ui, sans-serif;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
}

body {
  background:
    linear-gradient(rgba(250, 250, 250, 0.018), rgba(250, 250, 250, 0.018)),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E"),
    var(--bg);
  color: var(--text);
  font-size: 16px;
  letter-spacing: -0.01em;
}

.shell,
.main {
  background: transparent;
}

.sidebar {
  background: #0a0a0a;
  border-right: 1px solid var(--border, var(--line));
  box-shadow: none;
}

.sidebar .nav-item:hover,
.sidebar .side-agent:hover,
.sidebar .side-agent.sel,
.sidebar .nav-item.sel {
  background: transparent;
  color: var(--accent);
}

.brand-mark,
.glyph,
.user-av,
.type-chip,
.empty-ico,
.dropzone-ico,
.step-dot,
.new-card-plus {
  border-radius: 0;
  box-shadow: none;
}

.brand-mark,
.dropzone-ico,
.empty-ico,
.msg.user .msg-bubble,
.send-btn {
  background: var(--accent);
  color: var(--accent-ink);
}

.library,
.detail,
.create-view,
.chat-view {
  width: min(100%, 1320px);
  padding: 56px clamp(28px, 5vw, 80px);
}

h1,
.lib-head h1,
.detail-id h1 {
  color: var(--text);
  background: none;
  font-family: var(--display);
  font-size: clamp(52px, 8vw, 112px);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.9;
  text-transform: uppercase;
}

.sub,
.panel-sub,
.empty-sub,
.dropzone-sub,
.ac-desc,
.field-label,
.chat-foot,
.kn-stat,
.kb-id,
.metric em,
.ov-stat em {
  color: var(--muted);
}

.brand-name,
.ac-name,
.empty-title,
.dropzone-title,
.chat-id b,
.model-text b,
.match-top b {
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -0.03em;
}

.brand-sub,
.side-section,
.nav-count,
.side-empty,
.side-user em,
.model-text em,
.knowledge-file-copy em,
.chunk-meta,
.field-label em {
  color: var(--faint);
}

.side-section,
.section-label,
.model-provider,
.kn-thead,
.btn,
.tab,
.dropzone-action,
.clear-source,
.status,
.mini-chip,
.score-pill,
.ready-dot,
.ac-model,
.chat-model {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.metric,
.ov-stat,
.agent-card,
.side-card,
.kb-summary,
.knowledge-upload,
.ov-card,
.kn-table,
.chunk-drawer,
.retrieval-panel,
.msg.assistant .msg-bubble,
.toast,
.side-user,
.search,
.chat-input,
.text-input,
.text-area,
select.text-input,
.dropzone,
.chunk-card,
.retrieval-match,
.knowledge-file-drop,
.kb-health-status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.metric:hover,
.ov-stat:hover,
.agent-card:hover,
.ov-card:hover,
.side-card:hover,
.model-card:hover,
.new-card:hover {
  border-color: var(--accent);
  box-shadow: none;
  transform: none;
}

.metric b,
.ov-stat b,
.ac-model,
.chat-model,
.mini-chip,
.status,
.cite,
.ov-tool,
.score-pill {
  background: transparent;
  color: var(--accent);
  -webkit-background-clip: initial;
  background-clip: initial;
}

.metric,
.ov-stat {
  min-height: 124px;
}

.metric b,
.ov-stat b {
  font-family: var(--display);
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 900;
  letter-spacing: -0.06em;
}

.detail-id h1 {
  font-size: clamp(38px, 4.6vw, 66px);
  line-height: 0.96;
  max-width: 560px;
}

.knowledge-tab .ov-stat {
  min-height: 92px;
  padding: 16px 18px;
}

.knowledge-tab .ov-stat b {
  font-size: clamp(24px, 2.25vw, 34px);
  letter-spacing: 0;
  line-height: 1;
}

.kb-health-grid .ov-stat:first-child b {
  font-size: clamp(26px, 2.55vw, 38px);
}

.kb-health-status {
  min-height: 92px;
  font-size: 16px;
}

.section-label {
  min-height: 42px;
  min-width: 136px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  margin: 0 0 18px;
  padding: 0 18px;
  text-align: center;
  width: fit-content;
}

.section-label::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  background: var(--accent);
  animation: none;
}

.section-label + * {
  margin-top: 0;
}

.panel-head .section-label {
  margin-bottom: 14px;
}

.cfg-main > .section-label:not(:first-child),
.settings-grid .section-label,
.side-card .section-label,
.panel-head {
  margin-top: 10px;
}

.mini-chip,
.status,
.cite,
.ac-model,
.chat-model,
.score-pill,
.ready-dot,
.dropzone-types span,
.kb-health-status,
.ov-tool {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-2);
  border-radius: 0;
  line-height: 1;
  padding: 0 12px;
  text-align: center;
  white-space: nowrap;
}

.dropzone-types,
.msg-cites,
.ov-tools,
.ac-sources {
  gap: 10px;
}

.ac-model,
.chat-model {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
}

.msg-cites .cite {
  font-family: var(--font);
  justify-content: flex-start;
  letter-spacing: 0;
  max-width: min(360px, 100%);
  text-transform: none;
}

.btn {
  position: relative;
  min-height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 0;
}

.btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 2px;
  background: currentColor;
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 150ms ease;
}

.btn:hover,
.btn-primary:hover,
.btn-ghost:hover,
.btn-soft:hover {
  background: transparent;
  box-shadow: none;
  color: var(--accent-light);
  filter: none;
  transform: none;
}

.btn:hover::after {
  transform: scaleX(1.12);
}

.btn-ghost,
.btn-soft,
.icon-btn,
.glyph-opt,
.model-card,
.tab,
.clear-source {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  color: var(--text);
}

.icon-btn {
  width: 42px;
  height: 42px;
}

.icon-btn:hover,
.glyph-opt:hover,
.glyph-opt.sel,
.model-card:hover,
.model-card.sel,
.tab:hover,
.tab.sel {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
  box-shadow: none;
}

.model-card:hover .model-text b,
.model-card.sel .model-text b {
  color: #0a0a0a;
}

.glyph-picker {
  gap: 16px;
}

.glyph-opt {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.model-list {
  gap: 14px;
}

.model-card {
  min-height: 86px;
  align-items: center;
  padding: 16px;
}

.model-radio {
  border-color: var(--line-2);
}

.model-card.sel .model-radio {
  background: var(--accent);
  border-color: var(--accent);
}

.create-foot {
  width: 100%;
  margin-top: 32px;
  margin-inline: 0;
  padding: 18px clamp(16px, 2.4vw, 28px);
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.foot-info {
  min-width: 0;
  max-width: 620px;
  line-height: 1.4;
}

.foot-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-left: 24px;
}

.foot-actions .btn {
  min-height: 44px;
}

.text-input,
.text-area,
select.text-input,
.retrieval-input input,
.search,
.chat-input {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

select.text-input {
  text-align: center;
  text-align-last: center;
}

.text-input:focus,
.text-area:focus,
.retrieval-input input:focus,
.chat-input:focus-within,
.search:focus-within {
  border-color: var(--accent);
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.file-drop:focus-within {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 5px var(--bg);
}

.chat-input input:focus,
.chat-input input:focus-visible {
  outline: none;
  box-shadow: none;
}

.tabs {
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  gap: 0;
  padding: 0;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 132px;
  border-width: 0 1px 0 0;
  text-align: center;
}

.tab:last-child {
  border-right: 0;
}

.step-rail {
  gap: 14px;
}

.step-dot,
.step-node.active .step-dot,
.step-node.done .step-dot {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text);
}

.step-node.active .step-dot {
  border-color: var(--accent);
  color: var(--accent);
}

.step-line,
.step-line.done {
  background: var(--line-2);
}

.dropzone,
.knowledge-file-drop {
  background: transparent;
  border-style: solid;
}

.dropzone {
  min-height: 330px;
}

.file-drop:hover,
.file-drop:focus-within,
.file-drop.has-file,
.knowledge-file-drop:hover,
.knowledge-file-drop:focus-within,
.knowledge-file-drop.has-file {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: none;
  transform: none;
}

.dropzone-title {
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1;
  text-transform: uppercase;
}

.dropzone-action {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  padding: 0 18px;
  text-align: center;
}

.dropzone-action:hover {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: none;
  filter: none;
  transform: none;
}

.knowledge-upload,
.kb-workbench,
.retrieval-panel,
.settings-tab,
.configure-grid {
  gap: 24px;
}

.kb-workbench {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.chunk-drawer {
  width: 100%;
}

.knowledge-file-drop {
  gap: 18px;
  padding: 18px;
}

.kn-thead {
  background: var(--surface-2);
}

.kn-tr {
  border-color: var(--line);
}

.kn-tr.sel {
  background: var(--soft);
}

.source-name {
  color: var(--text);
}

.source-name:hover,
.kn-tr.sel .source-name {
  color: var(--accent);
}

.status.good,
.kb-health-status.good,
.ready-dot:not(.wait):not(.bad) {
  color: var(--green);
  border-color: rgba(37, 211, 102, 0.5);
}

.status.wait,
.kb-health-status.wait,
.ready-dot.wait {
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.5);
}

.status.bad,
.kb-health-status.bad,
.ready-dot.bad,
.msg.refused .msg-bubble {
  color: var(--red);
  border-color: rgba(255, 90, 61, 0.6);
}

.chat-head {
  border-color: var(--line);
}

.msg-bubble,
.msg.user .msg-bubble,
.msg.assistant .msg-bubble,
.chat-input,
.send-btn {
  border-radius: 0;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: var(--accent-ink);
}

.send-btn {
  border: 1px solid var(--accent);
}

.send-btn:hover {
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  filter: none;
  transform: none;
}

.text-area.auto-resize {
  min-height: 46px;
  overflow: hidden;
  resize: none;
}

.prompt-section-editor {
  display: grid;
  gap: 12px;
}

.prompt-editor-head {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

.template-badge {
  margin-left: 10px;
  padding: 2px 8px;
  border: 1px solid var(--accent, #ff5a1f);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #ff5a1f);
  white-space: nowrap;
}

.prompt-template-tools {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(200px, 280px) minmax(260px, 1fr);
}

.prompt-template-select {
  display: grid;
  gap: 6px;
}

.prompt-template-select span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.prompt-template-save {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(140px, 1fr) auto;
}

.prompt-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.prompt-section-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.prompt-section-head b {
  display: block;
  font-weight: 800;
}

.prompt-section-head em {
  color: var(--faint);
  display: block;
  font-size: 12px;
  font-style: normal;
}

.enhance-section-btn {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  min-height: 34px;
  padding: 7px 10px;
  text-transform: uppercase;
}

.enhance-section-btn:hover {
  border-color: var(--line-2);
  background: var(--surface-2);
}

@media (max-width: 760px) {
  .prompt-template-tools,
  .prompt-template-save {
    grid-template-columns: 1fr;
  }
}

.source-file-list {
  display: grid;
  gap: 8px;
  margin-top: -8px;
}

.knowledge-source-list {
  grid-column: 1 / -1;
  margin-top: 0;
}

.source-file-row {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 56px;
  padding: 10px 12px;
}

.source-file-row.source-file-failed {
  border-color: var(--bad);
}

.source-file-main {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.source-file-main svg {
  color: var(--accent);
  flex: 0 0 auto;
}

.source-file-copy {
  display: grid;
  min-width: 0;
}

.source-file-copy b,
.source-file-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-file-copy b {
  font-weight: 800;
}

.source-file-copy em {
  color: var(--faint);
  font-size: 12px;
  font-style: normal;
}

.source-file-error {
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-file-remove {
  flex: 0 0 auto;
  height: 36px;
  width: 36px;
}

.markdown-answer pre {
  background: #0a0a0a;
  border-color: var(--line-2);
}

.markdown-answer code {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.overview {
  gap: 24px;
}

.overview-hero,
.overview-grid,
.overview-side {
  display: grid;
  gap: 18px;
}

.overview-hero {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255, 61, 0, 0.12), transparent 48%),
    var(--surface);
  padding: clamp(20px, 3vw, 34px);
}

.overview-hero-main {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.overview-status {
  width: fit-content;
  min-height: 36px;
  border: 1px solid rgba(37, 211, 102, 0.5);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  padding: 0 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.overview-status.wait {
  border-color: rgba(245, 158, 11, 0.5);
  color: var(--amber);
}

.overview-status.bad {
  border-color: rgba(255, 90, 61, 0.6);
  color: var(--red);
}

.overview-hero h2 {
  color: var(--text);
  font-family: var(--display);
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.96;
  margin: 0;
  max-width: 820px;
  text-transform: uppercase;
}

.overview-hero p,
.overview-note,
.overview-empty-source {
  color: var(--muted);
  line-height: 1.55;
}

.overview-hero p {
  max-width: 680px;
}

.overview-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.overview-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  align-items: stretch;
}

.overview-side {
  align-content: start;
}

.overview-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
  padding: clamp(18px, 2.2vw, 24px);
}

.overview-card .ov-card-h {
  margin-bottom: 0;
}

.coverage-meter {
  height: 12px;
  border: 1px solid var(--line-2);
  background: #0a0a0a;
  overflow: hidden;
}

.coverage-meter span {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--accent);
}

.overview-kv {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.overview-kv-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.overview-kv-row span,
.overview-source-name span {
  color: var(--muted);
}

.overview-kv-row b {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-runtime .overview-kv-row {
  grid-template-columns: 1fr;
  gap: 4px;
}

.overview-runtime .overview-kv-row b {
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

.overview-source-list {
  display: grid;
  gap: 10px;
}

.overview-source {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 12px;
}

.overview-source-name {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.overview-source-name b {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-source-name span,
.overview-note,
.overview-empty-source {
  font-size: 13px;
}

.overview-empty-source {
  border: 1px dashed var(--line-2);
  padding: 18px;
}

@media (max-width: 980px) {
  h1,
  .lib-head h1,
  .detail-id h1 {
    font-size: clamp(44px, 16vw, 72px);
  }

  .detail-id h1 {
    font-size: clamp(34px, 10vw, 52px);
  }

  .knowledge-tab .ov-stat b,
  .kb-health-grid .ov-stat:first-child b {
    font-size: clamp(24px, 8vw, 34px);
  }

  .section-label {
    min-width: 120px;
    margin-bottom: 16px;
  }

  .overview-hero,
  .overview-grid,
  .overview-side,
  .deploy-create,
  .deploy-head,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .deploy-head {
    display: grid;
  }

  .deploy-summary,
  .deploy-new-fields {
    grid-template-columns: 1fr;
  }

  .deploy-tr {
    grid-template-columns: 1fr;
  }

  .deploy-thead {
    display: none;
  }

  .deploy-key {
    grid-template-columns: 1fr;
  }

  .overview-hero {
    align-items: start;
  }

  .overview-hero-actions {
    justify-content: flex-start;
  }

  .overview-hero h2 {
    font-size: 44px;
  }
}

@media (max-width: 640px) {
  .library,
  .detail,
  .create-view,
  .chat-view {
    padding: 34px 18px;
  }

  .metric,
  .ov-stat {
    min-height: 104px;
  }

  .glyph-picker {
    gap: 10px;
  }

  .mini-chip,
  .status,
  .cite,
  .ac-model,
  .chat-model,
  .score-pill,
  .ready-dot,
  .dropzone-types span {
    min-height: 32px;
    white-space: normal;
  }

  .create-foot {
    gap: 16px;
    padding: 16px;
  }

  .foot-actions {
    width: 100%;
    padding-left: 0;
  }

  .overview-hero-actions,
  .overview-hero-actions .btn {
    width: 100%;
  }

  .overview-hero-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .overview-hero-actions .btn {
    justify-content: center;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
  }

  .tab {
    min-width: 0;
    padding-inline: 8px;
  }

  .overview-status {
    white-space: normal;
  }

  .overview-hero h2 {
    font-size: 34px;
  }

  .overview-kv-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .overview-kv-row b {
    text-align: left;
  }

  .source-file-row {
    align-items: stretch;
  }
}

/* ===== AI connections (Settings) ===== */
.connections-settings { display: flex; flex-direction: column; gap: 22px; }
.lib-head-actions { display: flex; gap: 10px; align-items: center; }
.conn-loading { color: var(--muted); padding: 24px 4px; }
.conn-list { display: flex; flex-direction: column; gap: 14px; }
.conn-card {
  display: flex; justify-content: space-between; gap: 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.conn-card.disabled { opacity: 0.6; }
.conn-card-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.conn-card-head { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.conn-card-head b { color: var(--text); }
.conn-url { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.conn-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.conn-badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--soft); color: var(--accent); border: 1px solid var(--soft-line);
}
.conn-badge.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.conn-badge.muted { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.conn-models { display: flex; flex-wrap: wrap; gap: 6px; }
.conn-model-chip {
  font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 8px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
}
.conn-model-chip.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); cursor: pointer; }
.conn-card-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }

/* form overlay */
.conn-form-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); padding: 24px;
}
.conn-form {
  width: min(640px, 100%); max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-hover);
  display: flex; flex-direction: column; gap: 16px;
}
.conn-form-head { display: flex; align-items: center; justify-content: space-between; }
.conn-form-head h2 { margin: 0; font-size: 18px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.conn-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.conn-test-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.conn-test-result { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.conn-test-result.ok { color: var(--green); }
.conn-test-result.fail { color: var(--red); }
.conn-discovered { display: flex; flex-direction: column; gap: 8px; }
.conn-check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; }
.conn-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.conn-embedding-config {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2);
}
.conn-warning {
  display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; line-height: 1.4;
  color: var(--amber); background: rgba(217, 119, 6, 0.08);
  border: 1px solid rgba(217, 119, 6, 0.3); border-radius: var(--radius); padding: 10px 12px;
}
.conn-form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
