:root {
  --canvas: #f7f7f8;
  --paper: #ffffff;
  --ink: #0d0d0d;
  --muted: #676767;
  --quiet: #8f8f8f;
  --line: #e5e5e5;
  --hover: #ececec;
  --sidebar: #f9f9f9;
  --dawn: #f07b61;
  --dawn-soft: #fff0eb;
  --search: #4d6bfe;
  --display: "Songti SC", "Noto Serif SC", STSong, serif;
  --body: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body, button, input, textarea { font-family: var(--body); color: var(--ink); }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.xi-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: var(--ink);
}
.xi-mark::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 6px;
  height: 9px;
  border-radius: 10px 10px 2px 2px;
  background: var(--dawn);
}
.xi-mark::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  height: 1px;
  background: #fff;
  opacity: .9;
}
.xi-mark i,
.xi-mark i::before,
.xi-mark i::after {
  position: absolute;
  width: 1px;
  height: 4px;
  background: #fff;
}
.xi-mark i { top: 6px; left: 50%; }
.xi-mark i::before, .xi-mark i::after { content: ""; top: 2px; }
.xi-mark i::before { transform: translateX(-7px) rotate(-45deg); }
.xi-mark i::after { transform: translateX(6px) rotate(45deg); }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #f6f6f5;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 30px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.login-main {
  display: grid;
  place-items: center;
  padding: 42px 24px 80px;
}
.auth-card {
  width: min(420px, 100%);
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border: 1px solid #e7e7e4;
  border-radius: 24px;
  background: var(--paper);
}
.auth-heading { text-align: center; margin-bottom: 12px; }
.auth-heading h1 {
  margin: 0 0 12px;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.auth-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.field { display: grid; gap: 8px; }
.field label { font-size: 14px; font-weight: 600; }
.field input {
  display: block;
  width: 100%;
  height: 52px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: 0;
  background: #f3f3f2;
  font-size: 16px;
  transition: border-color .15s, background .15s;
}
.field input::placeholder { color: #9a9a9a; }
.field input:focus { border-color: #9d9d99; background: var(--paper); }
.form-error { min-height: 18px; margin: -4px 0 -5px; color: #c5362f; font-size: 13px; }
.primary-button {
  min-height: 50px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.primary-button:hover { background: #2b2b2b; }
.primary-button:active { transform: scale(.99); }
button:disabled { cursor: not-allowed; opacity: .45; }
.auth-switch { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.auth-switch button { border: 0; padding: 3px 5px; background: none; color: var(--ink); font-weight: 650; cursor: pointer; }
.auth-switch button:hover { text-decoration: underline; }
.login-footer { padding: 22px; text-align: center; color: var(--quiet); font-size: 12px; }

/* Chat shell */
.chat-page { height: 100vh; overflow: hidden; background: var(--paper); }
.chat-layout { height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  min-width: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--sidebar);
}
.side-brand { height: 44px; padding: 5px 8px; display: flex; align-items: center; gap: 10px; }
.side-brand b { font-size: 15px; letter-spacing: -.01em; }
.xi-mark.small { width: 28px; height: 28px; }
.xi-mark.small::before { left: 6px; right: 6px; bottom: 5px; height: 8px; }
.xi-mark.small i { top: 5px; }
.new-chat {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}
.new-chat span { font-size: 20px; font-weight: 300; }
.new-chat:hover { background: var(--hover); }
.conversation-list { margin-top: 17px; }
.conversation-items { display: grid; gap: 2px; }
.history-label { margin: 0; padding: 0 10px 8px; color: var(--quiet); font-size: 12px; font-weight: 600; }
.conversation-chip {
  position: relative;
  width: 100%;
  padding: 10px;
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color .12s ease;
}
.conversation-chip:hover,
.conversation-chip.context-open { background: #ededed; }
.conversation-chip.active { background: #e7e7e7; }
.conversation-chip:focus-visible { outline: 2px solid #a3a3a3; outline-offset: -2px; }
.conversation-chip span { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-chip small { color: var(--quiet); font-size: 11px; }
.conversation-empty { margin: 0; padding: 10px; color: var(--quiet); font-size: 12px; line-height: 1.5; }
.conversation-menu {
  position: fixed;
  z-index: 30;
  min-width: 148px;
  padding: 5px;
  border: 1px solid #dedede;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgb(0 0 0 / 10%);
}
.conversation-menu button {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #a33a36;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.conversation-menu button:hover,
.conversation-menu button:focus-visible { outline: 0; background: #f3eeee; }
.conversation-menu svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.sidebar-spacer { flex: 1; }
.mode-switch {
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.mode-switch:hover { background: var(--hover); }
.mode-switch-icon { font-size: 20px; }
.mode-switch > span:nth-child(2) { display: grid; gap: 2px; }
.mode-current,
.header-mode-label,
.option-title { min-width: 0; display: flex; align-items: center; gap: 7px; }
.mode-switch small { color: var(--quiet); font-size: 10px; }
.mode-switch b { font-size: 13px; }
.beta-tag {
  width: fit-content;
  padding: 2px 5px 1px;
  border: 1px solid #efb09f;
  border-radius: 5px;
  background: var(--dawn-soft);
  color: #a74832;
  font-size: 8px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.profile-block {
  width: 100%;
  min-height: 56px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.profile-block:hover { border-radius: 9px; background: var(--hover); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #dedede; font-size: 12px; font-weight: 700; }
.profile-copy { min-width: 0; display: grid; gap: 2px; }
.profile-copy b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: var(--quiet); font-size: 10px; }
.profile-arrow { color: var(--quiet); font-size: 17px; transform: translateX(-2px); }

.chat-main { min-width: 0; height: 100vh; display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; background: var(--paper); }
.sidebar-scrim { display: none; }
.sidebar-scrim[hidden] { display: none; }
.chat-header { padding: 0 22px; display: flex; align-items: center; gap: 10px; }
.header-mode { padding: 8px 10px; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 8px; background: none; font-weight: 650; cursor: pointer; }
.header-mode:hover { background: var(--canvas); }
.header-mode > span:last-child { color: var(--quiet); font-size: 12px; }
.menu-button { display: none; border: 0; background: none; font-size: 20px; }
.messages { overflow-y: auto; padding: 32px max(24px, calc((100% - 760px) / 2)) 28px; scroll-behavior: smooth; }
.welcome { max-width: 660px; margin: 21vh auto 0; text-align: center; }
.xi-mark.hero { width: 48px; height: 48px; margin-bottom: 24px; }
.xi-mark.hero::before { left: 10px; right: 10px; bottom: 9px; height: 14px; }
.xi-mark.hero::after { left: 8px; right: 8px; bottom: 8px; }
.xi-mark.hero i { top: 9px; height: 6px; }
.xi-mark.hero i::before { transform: translateX(-10px) rotate(-45deg); }
.xi-mark.hero i::after { transform: translateX(9px) rotate(45deg); }
.welcome h1 { margin: 0 0 12px; font-size: clamp(26px, 3vw, 32px); line-height: 1.25; letter-spacing: -.035em; }
.welcome p { margin: 0; color: var(--muted); font-size: 14px; }
.message-row { max-width: 760px; margin: 0 auto 28px; }
.message-inner { display: flex; align-items: flex-start; gap: 13px; }
.message-row.user .message-inner { justify-content: flex-end; }
.message-avatar { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-family: var(--display); font-size: 13px; }
.message-stack { min-width: 0; display: grid; gap: 5px; }
.message-row.user .message-stack { max-width: 78%; justify-items: end; }
.message-row.assistant .message-stack { max-width: calc(100% - 41px); }
.message-bubble { font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-row.user .message-bubble { max-width: 100%; padding: 10px 16px; border-radius: 18px; background: #f4f4f4; }
.message-row.assistant .message-bubble { padding-top: 2px; }
.message-bubble.markdown-content { min-width: 0; white-space: normal; }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content p { margin: .55em 0; }
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 { margin: 1.15em 0 .45em; font-family: var(--display); line-height: 1.35; letter-spacing: -.018em; }
.markdown-content h1 { font-size: 1.42em; }
.markdown-content h2 { font-size: 1.27em; }
.markdown-content h3 { font-size: 1.14em; }
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 { font-size: 1em; }
.markdown-content ul,
.markdown-content ol { margin: .55em 0; padding-left: 1.45em; }
.markdown-content ul ul,
.markdown-content ul ol,
.markdown-content ol ul,
.markdown-content ol ol { margin: .24em 0; }
.markdown-content li { margin: .24em 0; padding-left: .12em; }
.markdown-content li > p { margin: .18em 0; }
.markdown-content li::marker { color: #777772; }
.markdown-content .task-list { padding-left: .35em; list-style: none; }
.markdown-content .task-list-item { padding-left: 0; }
.markdown-content .task-list-item input { width: 14px; height: 14px; margin: 0 .48em 0 0; accent-color: var(--dawn); vertical-align: -.12em; }
.markdown-content blockquote { margin: .7em 0; padding: .55em .8em; border-left: 3px solid var(--dawn); border-radius: 0 7px 7px 0; background: var(--dawn-soft); color: #55514f; }
.markdown-content blockquote > :first-child { margin-top: 0; }
.markdown-content blockquote > :last-child { margin-bottom: 0; }
.markdown-content code { padding: .12em .34em; border-radius: 4px; background: #efefed; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; }
.markdown-content pre { max-width: 100%; margin: .7em 0; overflow-x: auto; padding: 13px 14px; border: 1px solid #dededb; border-radius: 9px; background: #f4f4f2; line-height: 1.55; white-space: pre; }
.markdown-content pre code { padding: 0; border-radius: 0; background: transparent; font-size: 12px; }
.markdown-content img { display: block; max-width: min(100%, 680px); height: auto; margin: .8em 0; border: 1px solid var(--line); border-radius: 10px; }
.markdown-content a { color: #3154c9; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.markdown-content a:hover { color: #1f3da5; }
.markdown-content hr { margin: 1em 0; border: 0; border-top: 1px solid var(--line); }
.markdown-content eq { display: inline; }
.markdown-content eq .katex { font-size: 1.04em; }
.markdown-content section { max-width: 100%; margin: .85em 0; overflow-x: auto; overflow-y: hidden; padding: .15em 0 .35em; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.markdown-content eqn { display: block; width: max-content; min-width: 100%; text-align: center; }
.markdown-content .katex-display { margin: 0; }
.markdown-content .katex-display > .katex { text-align: center; }
.markdown-content .katex-error { color: #9d3d32; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.markdown-table { max-width: 100%; margin: .75em 0; overflow-x: auto; }
.markdown-table table { width: 100%; border-collapse: collapse; font-size: .92em; }
.markdown-table th,
.markdown-table td { padding: 7px 9px; border: 1px solid #dfdfdc; text-align: left; vertical-align: top; }
.markdown-table th { background: #f3f3f1; font-weight: 700; }
.markdown-table .markdown-align-center { text-align: center; }
.markdown-table .markdown-align-right { text-align: right; }
.thinking-row { margin-bottom: 24px; }
.thinking-row .message-avatar { animation: thinking-avatar 1.8s ease-in-out infinite; }
.thinking-bubble { min-height: 30px; padding: 4px 10px 4px 0 !important; display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.thinking-dots { display: inline-flex; align-items: center; gap: 4px; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--dawn); animation: thinking-dot 1.15s ease-in-out infinite; }
.thinking-dots i:nth-child(2) { animation-delay: .14s; }
.thinking-dots i:nth-child(3) { animation-delay: .28s; }
.message-meta { min-height: 14px; display: flex; align-items: center; gap: 5px; color: #747474; font-size: 10px; line-height: 1.3; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.message-row.user .message-meta { justify-content: flex-end; padding-right: 4px; }
.message-meta time { cursor: help; }
.time-mark { width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: var(--dawn); box-shadow: 0 0 0 2px var(--dawn-soft); }
.message-status::before { content: "·"; margin-right: 5px; color: #b8b8b8; }
.message-row.is-pending .message-bubble { opacity: .78; }
.message-row.is-pending .time-mark { animation: dawn-pulse 1.3s ease-in-out infinite; }
.message-row.is-failed .message-bubble { box-shadow: inset 0 0 0 1px #edc9c0; }
.message-row.is-failed .message-status { color: #a34c3d; }
.message-row.is-new { animation: message-arrive .22s ease-out both; }

@keyframes message-arrive {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dawn-pulse {
  0%, 100% { opacity: .45; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1); }
}
@keyframes thinking-dot {
  0%, 65%, 100% { opacity: .3; transform: translateY(0); }
  32% { opacity: 1; transform: translateY(-3px); }
}
@keyframes thinking-avatar {
  0%, 100% { box-shadow: 0 0 0 0 var(--dawn-soft); }
  50% { box-shadow: 0 0 0 4px var(--dawn-soft); }
}
.composer-area { padding: 10px max(24px, calc((100% - 800px) / 2)) 13px; background: var(--paper); }
.composer {
  min-height: 112px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  border: 1px solid transparent;
  border-radius: 22px;
  background: #f3f3f2;
}
.composer:focus-within { border-color: #d0d0cd; }
.composer textarea { width: 100%; min-height: 46px; max-height: 180px; flex: 1; resize: none; border: 0; outline: 0; padding: 1px 3px 10px; background: transparent; line-height: 1.55; }
.composer textarea::placeholder { color: #8b8b8b; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-tools { min-width: 0; display: flex; align-items: center; gap: 7px; }
.retrieve-toggle { height: 34px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; border-radius: 18px; background: #e7e7e5; color: #62625f; font-size: 12px; font-weight: 600; cursor: pointer; }
.retrieve-toggle:hover { background: #dededb; color: #333; }
.retrieve-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.retrieve-toggle[aria-pressed="true"] { border-color: #bdc9ff; background: #e9edff; color: var(--search); }
.retrieve-toggle[aria-pressed="true"]:hover { background: #dfe5ff; }
.send-button { width: 36px; height: 36px; flex: 0 0 36px; border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 20px; cursor: pointer; }
.send-button:hover { background: #333; }
.composer-area > p { margin: 7px 0 0; text-align: center; color: var(--quiet); font-size: 10px; }
.document-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: #555552;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .035em;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 5%);
}

/* Mode selection */
.mode-layer { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(0 0 0 / 36%); backdrop-filter: blur(3px); }
.mode-dialog { position: relative; width: min(520px, 100%); padding: 34px; border-radius: 18px; background: var(--paper); box-shadow: 0 22px 70px rgb(0 0 0 / 18%); }
.dialog-close { position: absolute; top: 14px; right: 15px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.dialog-close:hover { background: var(--canvas); }
.xi-mark.dialog-mark { margin-bottom: 22px; }
.mode-dialog h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.03em; }
.mode-dialog > p { margin: 0 0 25px; color: var(--muted); font-size: 14px; }
.mode-options { display: grid; gap: 10px; }
.mode-option { min-height: 80px; padding: 14px 16px; display: grid; grid-template-columns: 34px 1fr 22px; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); text-align: left; cursor: pointer; }
.mode-option:hover { border-color: #bcbcbc; background: var(--canvas); }
.mode-option.selected { border-color: var(--ink); }
.option-icon { font-size: 22px; }
.mode-option > span:nth-child(2) { display: grid; gap: 5px; }
.mode-option .option-title { gap: 8px; }
.mode-option b { font-size: 15px; }
.mode-option small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.option-check { display: none; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-size: 11px; }
.mode-option.selected .option-check { display: grid; }

/* Account and knowledge library */
.user-layer { position: fixed; z-index: 25; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(0 0 0 / 36%); backdrop-filter: blur(3px); }
.user-dialog {
  position: relative;
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 30px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 22px 70px rgb(0 0 0 / 18%);
}
.user-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.user-dialog-header p { margin: 0 0 5px; color: var(--quiet); font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.user-dialog-header h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.user-dialog-header .dialog-close { position: static; margin: -6px -7px 0 0; flex: 0 0 auto; }
.user-identity { margin-top: 24px; display: flex; align-items: center; gap: 11px; }
.user-avatar { width: 42px; height: 42px; flex: 0 0 42px; background: var(--ink); color: #fff; font-family: var(--display); font-size: 15px; }
.user-identity > span:last-child { min-width: 0; display: grid; gap: 3px; }
.user-identity b { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-manager { margin-top: 25px; }
.knowledge-manager > header { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding: 0 2px 10px; border-bottom: 1px solid var(--line); }
.knowledge-manager-heading { display: flex; align-items: baseline; gap: 8px; }
.knowledge-manager-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.knowledge-manager h3 { margin: 0; font-size: 15px; letter-spacing: -.015em; }
.knowledge-manager header small { color: var(--quiet); font-size: 10px; }
.knowledge-upload-button { padding: 7px 10px; border: 1px solid #d5d5d2; border-radius: 8px; background: #f2f2f0; color: #50504d; font-size: 10px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.knowledge-upload-button:hover { border-color: #bdbdb9; background: #eaeae7; color: #292928; }
.knowledge-upload-button:disabled { opacity: .55; cursor: default; }
.knowledge-manager-files { max-height: 310px; overflow-y: auto; padding-top: 5px; }
.knowledge-manager-empty { margin: 0; padding: 32px 12px; color: var(--quiet); text-align: center; font-size: 12px; line-height: 1.6; }
.knowledge-manager-file {
  min-width: 0;
  min-height: 58px;
  padding: 9px 2px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #ededeb;
}
.knowledge-manager-file .document-mark { width: 34px; height: 34px; background: #f2f2f0; }
.managed-file-copy { min-width: 0; display: grid; gap: 3px; }
.managed-file-copy b { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.managed-file-copy small { color: var(--quiet); font-size: 10px; }
.managed-file-status { padding: 4px 7px; border-radius: 10px; background: #eeeeec; color: #696966; font-size: 9px; white-space: nowrap; }
.knowledge-manager-file[data-status="ready"] .managed-file-status { background: #e6ebe7; color: #506254; }
.knowledge-manager-file[data-status="failed"] .managed-file-status,
.knowledge-manager-file[data-status="delete_failed"] .managed-file-status { background: #f0e7e5; color: #8c5148; }
.knowledge-manager-file[data-status="deleting"] { opacity: .58; }
.managed-file-delete { padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: #8a5c55; font-size: 10px; cursor: pointer; }
.managed-file-delete:hover { background: #f2eae8; color: #883f36; }
.managed-file-delete.confirm { background: #9b4c42; color: #fff; }
.managed-file-delete:disabled { background: transparent; }
.user-dialog-footer { margin-top: 20px; padding-top: 16px; display: flex; justify-content: flex-end; border-top: 1px solid var(--line); }
.logout-button { padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: #8a4c44; font-size: 11px; cursor: pointer; }
.logout-button:hover { background: #f2eae8; }

.interrupt-card { max-width: 700px; margin: 10px auto 28px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--canvas); }
.interrupt-card h3 { margin: 0 0 9px; font-size: 16px; }
.interrupt-card > p { color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.knowledge-option { margin: 8px 0; padding: 11px; display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.knowledge-option span { display: grid; gap: 3px; }
.knowledge-option b { font-size: 13px; }
.knowledge-option small { color: var(--muted); font-size: 11px; }
.primary-button.compact { min-height: 40px; margin-top: 10px; padding: 9px 15px; font-size: 12px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 94px; padding: 11px 16px; border-radius: 9px; background: #202020; color: white; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

button:focus { outline: 0; }
button:focus-visible { outline: 2px solid #777; outline-offset: 2px; }
input:focus-visible, textarea:focus-visible { outline: 0; }

@media (max-width: 760px) {
  .login-brand { padding: 20px; }
  .login-main { padding: 35px 22px 75px; }
  .auth-heading h1 { font-size: 28px; }
  .auth-card { padding: 28px 22px; border-radius: 20px; }
  .chat-layout { display: block; }
  body.sidebar-visible { overflow: hidden; }
  .sidebar { position: fixed; z-index: 16; inset: 0 auto 0 0; width: 270px; box-shadow: 10px 0 35px rgb(0 0 0 / 14%); transform: translateX(-102%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; z-index: 15; inset: 0; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: rgb(20 20 20 / 32%); opacity: 1; cursor: default; transition: opacity .2s ease; -webkit-tap-highlight-color: transparent; }
  .chat-main { height: 100vh; }
  .menu-button { display: block; cursor: pointer; }
  .chat-header { padding: 0 13px; }
  .messages { padding: 25px 15px; }
  .welcome { margin-top: 18vh; }
  .message-row.user .message-stack { max-width: 88%; }
  .markdown-content section { margin-right: -8px; padding-right: 8px; }
  .composer-area { padding: 9px 12px 10px; }
  .mode-dialog { padding: 28px 20px 22px; }
  .user-layer { padding: 10px; }
  .user-dialog { max-height: calc(100vh - 20px); padding: 24px 18px 18px; border-radius: 17px; }
  .knowledge-manager > header { align-items: flex-start; }
  .knowledge-manager-actions { max-width: 190px; flex-wrap: wrap; gap: 7px; }
  .knowledge-manager-actions small { width: 100%; text-align: right; line-height: 1.4; }
  .knowledge-manager-file { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .managed-file-status { display: none; }
}

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