:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0d0d0f;
  --panel-soft: #151516;
  --panel-raised: #1f1f21;
  --line: #2a2a2d;
  --line-soft: #222225;
  --text: #f4f4f5;
  --muted: #aaaab0;
  --subtle: #77777f;
  --accent: #47c6ff;
  --accent-strong: #11a8f5;
  --good: #66d19e;
  --danger: #ff7070;
  --bubble-user: #2f2f31;
  --bubble-assistant: transparent;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
  --sidebar-width: 260px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  max-width: 100vw;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.hidden {
  display: none !important;
}

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

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  min-height: 100vh;
  padding: 28px;
  place-items: center;
  background:
    radial-gradient(circle at top left, rgba(71, 198, 255, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.06), transparent 26%),
    rgba(5, 5, 5, 0.9);
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(15, 15, 17, 0.94);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand h1,
.auth-brand p {
  margin: 0;
}

.auth-brand h1 {
  font-size: 26px;
}

.auth-brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auth-tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #111113;
  color: var(--muted);
}

.auth-tab.active {
  border-color: rgba(71, 198, 255, 0.35);
  background: rgba(71, 198, 255, 0.14);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-inline,
.auth-email-row,
.auth-code-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.auth-inline {
  justify-content: space-between;
}

.auth-code-row input {
  flex: 1;
}

.auth-email-row input {
  flex: 1;
}

.auth-email-row .ghost-button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.auth-submit {
  min-height: 46px;
  justify-content: center;
}

.auth-hint,
.auth-note,
.auth-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-note {
  color: var(--accent);
}

.auth-status.error {
  color: var(--danger);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line-soft);
  background: #090909;
}

.sidebar-head,
.topbar,
.modal-head,
.modal-actions,
.sidebar-footer,
.composer {
  display: flex;
  align-items: center;
}

.sidebar-head {
  height: 58px;
  justify-content: space-between;
  padding: 10px 14px;
}

.brand-button,
.profile-button,
.action-button,
.conversation-item,
.text-icon-button,
.ghost-button,
.primary-button {
  border-radius: 8px;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 8px 8px;
  background: transparent;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.brand-title {
  overflow: hidden;
  color: #f6f6f7;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover,
.text-icon-button:hover,
.action-button:hover,
.conversation-item:hover,
.profile-button:hover,
.ghost-button:hover {
  background: var(--panel-raised);
  color: var(--text);
}

.icon-button svg,
.text-icon-button svg,
.action-button svg,
.search-box svg,
.model-pill svg {
  width: 18px;
  height: 18px;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  padding: 4px 14px 14px;
}

.action-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  height: 38px;
  padding: 0 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.search-box {
  display: flex;
  align-items: center;
  height: 38px;
  gap: 10px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
}

.search-box:focus-within {
  background: var(--panel-soft);
}

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

.conversation-groups {
  flex: 1;
  min-height: 0;
  padding: 8px 8px 12px;
  overflow-y: auto;
}

.group-label {
  padding: 10px 8px 8px;
  color: #d8d8dc;
  font-size: 13px;
  font-weight: 700;
}

.conversation-list {
  display: grid;
  gap: 3px;
}

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

.conversation-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  background: transparent;
  color: #e8e8eb;
  text-align: left;
}

.conversation-item.active {
  background: #303033;
}

.conversation-delete {
  width: 30px;
  height: 30px;
  opacity: 0;
  pointer-events: none;
  color: var(--subtle);
  transition:
    opacity 140ms ease,
    color 140ms ease,
    background 140ms ease;
}

.conversation-row:hover .conversation-delete,
.conversation-row:focus-within .conversation-delete,
.conversation-row.active .conversation-delete {
  opacity: 1;
  pointer-events: auto;
}

.conversation-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item small {
  color: var(--subtle);
  font-size: 11px;
}

.sidebar-footer {
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
}

.profile-button {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 10px;
  padding: 6px;
  background: transparent;
  text-align: left;
}

.profile-button span:last-child {
  display: grid;
  min-width: 0;
}

.profile-button strong,
.profile-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-button strong {
  font-size: 14px;
}

.profile-button small {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #0d87e9;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.main-panel {
  position: relative;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  gap: 10px;
  padding: 0 18px;
}

.sidebar-toggle,
.mobile-close {
  display: none;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  max-width: min(420px, 60vw);
  gap: 8px;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--text);
  user-select: none;
}

.model-pill:hover {
  background: var(--panel-raised);
}

.model-pill span {
  font-size: 18px;
  font-weight: 750;
}

.model-pill strong {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-spacer {
  flex: 1;
  min-width: 0;
}

.registrations-modal {
  max-width: 760px;
}

.registrations-list {
  display: grid;
  gap: 12px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 2px;
}

.registration-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel);
}

.registration-main {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}

.registration-main span {
  white-space: nowrap;
}

.registrations-actions {
  display: flex;
  gap: 8px;
}

.ghost-button.approve-registration {
  border-color: #1b8f4b;
  background: rgba(27, 143, 75, 0.12);
  color: #6fd79d;
}

.ghost-button.reject-registration {
  border-color: #c53a3a;
  background: rgba(197, 58, 58, 0.12);
  color: #ff9a9a;
}

.registrations-empty {
  color: var(--muted);
  font-size: 14px;
}

.text-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
}

.chat-area {
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message-list {
  display: grid;
  width: min(100%, 860px);
  gap: 22px;
  margin: 0 auto;
  padding: 22px 18px 190px;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  align-content: center;
  gap: 22px;
  padding: 32px 18px 180px;
}

.empty-state.hidden {
  display: none;
}

.empty-orbit {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border: 1px solid #323238;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(71, 198, 255, 0.22), transparent 36%),
    #111113;
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.02);
}

.empty-orbit span {
  color: var(--accent);
  font-size: 17px;
  font-weight: 850;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: 0;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(780px, 100%);
  gap: 10px;
}

.quick-prompts button {
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111113;
  color: #dbdbe0;
  line-height: 1.35;
  text-align: left;
}

.quick-prompts button:hover {
  border-color: #414146;
  background: #18181a;
}

.message {
  position: relative;
  display: grid;
  gap: 8px;
  padding-bottom: 34px;
}

.message.user {
  justify-items: end;
}

.message.assistant {
  justify-items: start;
}

.knowledge-sources {
  display: grid;
  gap: 8px;
  width: min(100%, 680px);
}

.knowledge-sources-label {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.knowledge-source-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.knowledge-source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.knowledge-source-head strong {
  font-size: 13px;
}

.knowledge-source-head span {
  color: var(--subtle);
  font-size: 12px;
}

.knowledge-source-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.bubble {
  max-width: min(100%, 680px);
  border-radius: 8px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  padding: 14px 16px;
  background: var(--bubble-user);
}

.message.assistant .bubble {
  padding: 4px 0;
  background: var(--bubble-assistant);
}

.bubble.empty {
  min-width: 180px;
  color: var(--muted);
}

.message-tools {
  position: absolute;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.message:hover .message-tools {
  opacity: 1;
  pointer-events: auto;
}

.message.user .message-tools {
  right: 0;
  left: auto;
}

.message-tools .icon-button {
  width: 32px;
  height: 32px;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: min(100%, 680px);
}

.message-image-button {
  display: block;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

.message-images img,
.generated-image {
  display: block;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.message-images img {
  width: 180px;
  max-height: 160px;
}

.generated-image-wrap {
  display: grid;
  width: min(520px, 100%);
  gap: 8px;
  margin: 0;
}

.generated-image-button {
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.generated-image {
  width: 100%;
  transition:
    border-color 0.16s ease,
    filter 0.16s ease;
}

.generated-image-button:hover .generated-image {
  border-color: rgba(71, 198, 255, 0.72);
  filter: brightness(1.03);
}

.generated-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.generated-image-actions .text-icon-button {
  min-height: 32px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 13px;
}

.image-loading-card {
  display: grid;
  width: min(520px, calc(100vw - 40px));
  gap: 10px;
}

.image-loading-preview {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  place-items: center;
  border: 1px solid #333338;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 36%),
    #17171a;
}

.image-loading-preview::before {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  content: "";
}

.image-loading-preview svg {
  z-index: 1;
  width: 34px;
  height: 34px;
  color: #c9c9cf;
  opacity: 0.82;
}

.image-loading-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 0%,
    transparent 34%,
    rgba(255, 255, 255, 0.12) 47%,
    transparent 60%,
    transparent 100%
  );
  animation: imageSheen 1.8s infinite ease-in-out;
  transform: translateX(-70%);
}

.image-loading-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  color: var(--muted);
}

.image-loading-meta strong {
  color: var(--text);
  font-size: 15px;
}

.image-loading-meta > span:not(.loading-dots) {
  grid-column: 1 / 2;
  font-size: 13px;
}

.image-loading-meta .loading-dots {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.loading-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.1s infinite ease-in-out;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes imageSheen {
  0% {
    transform: translateX(-70%);
  }
  65%,
  100% {
    transform: translateX(70%);
  }
}

.composer-wrap {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  display: grid;
  gap: 8px;
  width: min(100%, 940px);
  margin: 0 auto;
  padding: 16px 20px 14px;
  background: linear-gradient(to top, var(--bg) 78%, rgba(5, 5, 5, 0));
}

.attachment-strip {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 2px;
}

.attachment-strip.visible {
  display: flex;
}

.attachment-chip {
  position: relative;
  display: grid;
  width: 86px;
  height: 64px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.attachment-chip img {
  width: 100%;
  height: 100%;
  cursor: zoom-in;
  object-fit: cover;
}

.attachment-chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
}

.composer {
  position: relative;
  display: block;
  padding: 1px;
  border: 0;
  border-radius: 34px;
  background: linear-gradient(105deg, #8aa7ff 0%, #d6a4ff 53%, #f5c8aa 100%);
  box-shadow:
    0 20px 46px rgba(94, 116, 173, 0.22),
    0 2px 6px rgba(0, 0, 0, 0.08);
  transition:
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.composer.dragging {
  box-shadow:
    0 24px 52px rgba(111, 142, 232, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}

.composer-field {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 20px 20px 14px;
  border-radius: 33px;
  background: #f4f4f5;
}

.mode-tabs {
  display: flex;
  align-items: center;
  width: max-content;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: #ececee;
}

.mode-tab {
  min-width: 64px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
  color: #5f636f;
  font-size: 14px;
}

.mode-tab.active {
  background: #f7f8fb;
  color: #2563ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 255, 0.18);
}

.composer textarea {
  width: 100%;
  max-height: 220px;
  min-height: 110px;
  padding: 0;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #2a2d36;
  line-height: 1.62;
  font-size: 18px;
}

.composer textarea::placeholder {
  color: #b2b4bc;
}

.composer-lead {
  margin: 0;
  color: #a4a7af;
  font-size: 32px;
  line-height: 1.15;
  font-weight: 500;
}

.composer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer .icon-button {
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.attach-button {
  color: #2e2f35;
  background: transparent;
}

.attach-button:hover {
  background: #ebedf1;
}

.send-button {
  background: #eceef2;
  color: #9ea3af;
}

.send-button:hover {
  background: #e3e6ed;
  color: #6e7687;
}

.disclaimer {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-backdrop.open {
  display: grid;
}

.modal-backdrop.image-viewer {
  background: rgba(0, 0, 0, 0.82);
}

.image-viewer-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1180px, calc(100vw - 36px));
  height: min(860px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f0f11;
  box-shadow: var(--shadow);
}

.image-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.image-viewer-head strong {
  font-size: 15px;
}

.image-viewer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.image-viewer-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 14px;
  overflow: auto;
}

.image-viewer-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111113;
  box-shadow: var(--shadow);
}

.knowledge-modal {
  width: min(980px, 100%);
}

.knowledge-layout {
  display: grid;
  gap: 18px;
  min-height: 0;
  padding: 18px 20px 22px;
  overflow-y: auto;
}

.knowledge-toolbar {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
  background:
    linear-gradient(135deg, rgba(71, 198, 255, 0.12), transparent 42%),
    rgba(20, 20, 22, 0.94);
}

.knowledge-toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.knowledge-scope-row select {
  height: 42px;
  min-width: 180px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #09090a;
  color: var(--text);
}

.knowledge-scope-row select:focus {
  border-color: rgba(71, 198, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(71, 198, 255, 0.12);
}

.knowledge-hint,
.knowledge-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.knowledge-import-row input {
  flex: 1 1 420px;
  height: 42px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #09090a;
  color: var(--text);
}

.knowledge-import-row input:focus {
  border-color: rgba(71, 198, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(71, 198, 255, 0.12);
}

.knowledge-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.knowledge-summary strong {
  font-size: 15px;
}

.knowledge-browse-row {
  align-items: stretch;
}

.knowledge-search-field {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #09090a;
}

.knowledge-search-field svg {
  width: 16px;
  height: 16px;
  color: var(--subtle);
  flex: 0 0 auto;
}

.knowledge-search-field input,
.knowledge-browse-row select {
  height: 42px;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.knowledge-search-field input {
  flex: 1 1 auto;
}

.knowledge-browse-row select {
  flex: 0 0 180px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #09090a;
}

.knowledge-search-field:focus-within,
.knowledge-browse-row select:focus {
  border-color: rgba(71, 198, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(71, 198, 255, 0.12);
}

.knowledge-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.knowledge-filter-chip {
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--subtle);
  font-size: 13px;
  cursor: pointer;
  transition: 160ms ease;
}

.knowledge-filter-chip:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.knowledge-filter-chip.active {
  border-color: rgba(71, 198, 255, 0.5);
  background: rgba(71, 198, 255, 0.12);
  color: #dff6ff;
}

.knowledge-filter-chip.hidden {
  display: none;
}

.knowledge-empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 34px 20px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.knowledge-empty-state.hidden {
  display: none;
}

.knowledge-empty-state svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.knowledge-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.knowledge-empty-state p {
  max-width: 620px;
  margin: 0;
  line-height: 1.65;
}

.knowledge-document-list {
  display: grid;
  gap: 14px;
}

.knowledge-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(17, 17, 19, 0.72);
}

.knowledge-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.knowledge-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.knowledge-section-head strong {
  color: var(--text);
  font-size: 15px;
}

.knowledge-section-body {
  display: grid;
  gap: 12px;
}

.knowledge-section.collapsed .knowledge-section-body {
  display: none;
}

.knowledge-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 60%),
    #111113;
  transition: border-color 160ms ease, transform 160ms ease;
}

.knowledge-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.knowledge-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.knowledge-card-main {
  min-width: 0;
}

.knowledge-card-side {
  flex: 0 0 auto;
}

.knowledge-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.knowledge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.knowledge-meta span {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--subtle);
  font-size: 12px;
}

.knowledge-readonly {
  padding: 5px 8px;
  color: var(--subtle);
  font-size: 12px;
}

.knowledge-preview {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.knowledge-preview.collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.knowledge-preview.expanded {
  display: block;
}

.knowledge-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.knowledge-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.knowledge-link {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.knowledge-link:hover {
  text-decoration: underline;
}

.knowledge-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 0 0;
}

.knowledge-pagination span {
  color: var(--muted);
  font-size: 13px;
}

.knowledge-pagination .ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .knowledge-layout {
    padding: 14px 14px 18px;
  }

  .knowledge-toolbar {
    padding: 14px;
  }

  .knowledge-browse-row select {
    flex-basis: 100%;
  }

  .knowledge-section,
  .knowledge-card {
    padding: 14px;
  }
}

.modal-head {
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h2,
.modal-head p {
  margin: 0;
}

.modal-head h2 {
  font-size: 20px;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-height: 0;
  padding: 18px 20px;
  overflow-y: auto;
}

.setting-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.setting-field.wide,
.settings-section.wide {
  grid-column: 1 / -1;
}

.settings-section {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.settings-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.setting-field span {
  color: #d8d8dd;
  font-size: 13px;
  font-weight: 650;
}

.setting-field input,
.setting-field textarea,
.setting-field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #09090a;
  color: var(--text);
}

.setting-field input,
.setting-field select {
  height: 42px;
  padding: 0 12px;
}

.setting-field textarea {
  resize: vertical;
  min-height: 92px;
  padding: 10px 12px;
  line-height: 1.6;
}

.setting-field input:focus,
.setting-field textarea:focus,
.setting-field select:focus {
  border-color: rgba(71, 198, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(71, 198, 255, 0.12);
}

.password-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.password-line .icon-button {
  height: 42px;
  border: 1px solid var(--line);
  background: #09090a;
}

.modal-actions {
  position: sticky;
  bottom: 0;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line-soft);
  background: #111113;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  color: #dddde2;
  cursor: pointer;
}

.switch input {
  display: none;
}

.switch span {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #3a3a3d;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--accent-strong);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch b {
  font-size: 14px;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  padding: 0 14px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.primary-button {
  background: var(--text);
  color: #111;
  font-weight: 750;
}

.toast {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18181a;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle,
  .mobile-close {
    display: inline-grid;
  }

  .topbar {
    width: 100%;
    max-width: 100vw;
    padding: 0 10px;
    overflow: hidden;
  }

  .main-panel,
  .chat-area,
  .composer-wrap {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .model-pill {
    flex: 1 1 auto;
    max-width: calc(100vw - 184px);
    min-width: 0;
  }

  .model-pill span {
    font-size: 20px;
  }

  .text-icon-button {
    width: 38px;
    justify-content: center;
    padding: 0;
  }

  .text-icon-button span {
    display: none;
  }

  .message-list {
    padding-inline: 14px;
  }

  .empty-state {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .quick-prompts,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .knowledge-toolbar-row,
  .knowledge-summary,
  .knowledge-card-head,
  .knowledge-source-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .knowledge-import-row input {
    width: 100%;
    flex-basis: auto;
  }

  .quick-prompts {
    width: 100%;
    max-width: calc(100vw - 36px);
  }

  .setting-field.wide,
  .settings-section.wide {
    grid-column: auto;
  }

  .composer-wrap {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    padding-inline: 0;
  }

  .composer {
    width: 100%;
    border-radius: 24px;
  }

  .composer-field {
    padding: 16px 14px 12px;
    border-radius: 23px;
  }

  .composer-lead {
    font-size: 24px;
  }

  .composer textarea {
    min-height: 96px;
    font-size: 16px;
  }

  .attachment-strip {
    padding: 0 0 2px;
  }

  .disclaimer {
    padding: 0 6px;
    overflow-wrap: anywhere;
    line-height: 1.45;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .switch {
    width: 100%;
    margin-right: 0;
  }
}
