:root {
  color-scheme: light;
  --bg: #f5f7fc;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --surface-hover: #eef2ff;
  --line: rgba(120, 140, 180, 0.18);
  --line-strong: rgba(120, 140, 180, 0.32);
  --text: #151a20;
  --muted: #68717c;
  --faint: #97a1ad;
  --brand: #4f63ff;
  --brand-strong: #635bff;
  --brand-gradient: linear-gradient(135deg, #4f63ff, #6c5cff);
  --accent: #00a884;
  --danger: #d93a3a;
  --warning: #b7791f;
  --bubble-self: #dfe8ff;
  --bubble-other: #ffffff;
  --shadow: 0 16px 40px rgba(40, 60, 120, 0.1);
  --shadow-floating: 0 22px 52px rgba(40, 60, 120, 0.16);
  --radius: 16px;
  --rail-width: clamp(3.75rem, 4.5vw, 5rem);
  --list-width: 360px;
  --detail-width: 312px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: radial-gradient(circle at 12% 0%, rgba(108, 92, 255, 0.08), transparent 32%), var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail-width) var(--list-width) minmax(0, 1fr);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
}

.app-shell.is-detail-open {
  grid-template-columns: var(--rail-width) var(--list-width) minmax(0, 1fr);
}

.rail {
  background: rgba(255, 255, 255, 0.78);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 10px;
}

.rail-brand {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.rail-brand__img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.rail-btn,
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.rail-btn img,
.icon-btn img {
  width: 21px;
  height: 21px;
}

.rail-btn:hover,
.icon-btn:hover,
.rail-btn.is-active {
  background: var(--surface-hover);
}

.rail-btn.is-active {
  box-shadow: inset 3px 0 0 var(--brand);
  color: var(--brand);
}

.conversation-list {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-top {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}

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

.profile-chip__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.profile-chip strong,
.profile-chip small {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.profile-chip small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  margin: 0 14px 10px;
  min-height: 42px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 12px;
}

.search-row > img {
  width: 18px;
  height: 18px;
  opacity: 0.56;
}

.search-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
}

.list-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 14px 10px;
}

.tab-btn {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
}

.tab-btn.is-active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand-gradient);
  box-shadow: 0 10px 22px rgba(79, 99, 255, 0.22);
}

.list-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0 8px 10px;
}

.list-scroll,
.message-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 91, 255, 0.48) transparent;
}

.list-scroll::-webkit-scrollbar,
.message-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.list-scroll::-webkit-scrollbar-track,
.message-list::-webkit-scrollbar-track {
  background: transparent;
}

.list-scroll::-webkit-scrollbar-thumb,
.message-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.42);
  background-clip: padding-box;
}

.list-scroll::-webkit-scrollbar-thumb:hover,
.message-list::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 99, 255, 0.62);
  background-clip: padding-box;
}

.conversation-item {
  width: 100%;
  min-height: 74px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  text-align: left;
  color: var(--text);
}

.conversation-item:hover,
.conversation-item.is-active {
  background: #e9edf2;
}

.conversation-item__avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
}

.conversation-item__body {
  min-width: 0;
}

.conversation-item__name,
.conversation-item__preview {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-item__name {
  font-size: 15px;
  font-weight: 650;
}

.conversation-item__preview {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.conversation-item__meta {
  color: var(--faint);
  font-size: 12px;
  align-self: start;
  padding-top: 7px;
}

.chat-pane {
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  position: relative;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  overflow: hidden;
  background: linear-gradient(180deg, #f8faff 0%, #f3f6fb 100%);
}

.chat-head {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.mobile-back {
  display: none;
}

.mobile-back span {
  font-size: 32px;
  line-height: 1;
}

.chat-head__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.chat-head__titles {
  min-width: 0;
  flex: 1;
}

.chat-head__titles h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.22;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-head__titles p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-head__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.roundtable-error-btn {
  color: #ff4d4f;
  background: rgba(255, 77, 79, 0.08);
}

.roundtable-error-btn img {
  filter: invert(41%) sepia(76%) saturate(2240%) hue-rotate(331deg) brightness(101%) contrast(101%);
}

.roundtable-error-popover {
  position: absolute;
  top: 74px;
  right: 18px;
  z-index: 26;
  width: min(420px, calc(100vw - 36px));
  max-height: min(420px, calc(100dvh - 112px));
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-floating);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.roundtable-error-head {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 0 16px;
}

.roundtable-error-head strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.roundtable-error-popover pre {
  margin: 0;
  max-height: calc(min(420px, calc(100dvh - 112px)) - 48px);
  overflow: auto;
  padding: 14px 16px 16px;
  color: var(--muted);
  font: 12px/1.58 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.roundtable-error-popover pre::-webkit-scrollbar {
  width: 8px;
}

.roundtable-error-popover pre::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.42);
  background-clip: padding-box;
}

.message-list {
  min-height: 0;
  overflow: auto;
  padding: 24px 20px clamp(7.25rem, 12vh, 9.25rem);
  overscroll-behavior: contain;
}

.empty-state {
  height: 100%;
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state img {
  width: 88px;
  height: 88px;
  margin-bottom: 12px;
}

.empty-state h2 {
  color: var(--text);
  margin: 0 0 8px;
}

.empty-state p {
  max-width: 360px;
  margin: 0;
  line-height: 1.6;
}

.message-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  margin: 14px 0;
  max-width: 780px;
}

.message-row.is-self {
  grid-template-columns: minmax(0, 1fr) 38px;
  margin-left: auto;
}

.message-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.message-avatar--mentionable {
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.message-avatar--mentionable:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(22, 119, 255, 0.18);
}

.message-row.is-self .message-avatar {
  grid-column: 2;
}

.message-bubble {
  min-width: 0;
}

.message-row.is-self .message-bubble {
  grid-column: 1;
  text-align: right;
}

.message-name {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-content {
  display: inline-block;
  max-width: min(560px, 100%);
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--bubble-other);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(40, 60, 120, 0.06);
  text-align: left;
  line-height: 1.58;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-row.is-self .message-content {
  color: #fff;
  background: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(79, 99, 255, 0.22);
}

.message-mention {
  border: 0;
  border-radius: 999px;
  background: rgba(22, 119, 255, 0.1);
  color: #0b63d8;
  padding: 0 5px;
  margin: 0 1px;
}

.message-mention:hover {
  background: rgba(22, 119, 255, 0.18);
}

.message-row.is-self .message-mention {
  color: #f8fbff;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.message-row.is-self .message-mention:hover {
  background: rgba(255, 255, 255, 0.32);
}

.message-content img.message-image {
  max-width: min(320px, 70vw);
  border-radius: var(--radius);
  margin-top: 6px;
}

.message-meta {
  margin-top: 4px;
  color: var(--faint);
  font-size: 11px;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: blink 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

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

.composer {
  position: absolute;
  left: clamp(1rem, 2vw, 1.5rem);
  right: clamp(1rem, 2vw, 1.5rem);
  bottom: clamp(0.85rem, 2vh, 1.35rem);
  z-index: 8;
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-floating);
  backdrop-filter: blur(18px);
  padding: 10px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 8px 10px;
}

.attachment-preview {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.attachment-chip img {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 128px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  line-height: 1.5;
  padding: 10px 2px;
}

.send-btn {
  min-width: 108px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
}

.send-btn:hover {
  box-shadow: 0 12px 24px rgba(79, 99, 255, 0.28);
}

.send-btn img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.mention-popover {
  position: absolute;
  left: min(120px, 16vw);
  bottom: calc(100% - 6px);
  z-index: 24;
  width: min(320px, calc(100% - 36px));
  max-height: 286px;
  overflow: auto;
  border: 1px solid rgba(120, 140, 180, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(40, 60, 120, 0.16);
  padding: 8px;
  backdrop-filter: blur(14px);
}

.mention-row {
  width: 100%;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  padding: 8px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  text-align: left;
}

.mention-row:hover,
.mention-row.is-active {
  background: #eef6ff;
}

.mention-row img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.mention-row strong,
.mention-row small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mention-row small {
  color: var(--muted);
  margin-top: 2px;
  font-size: 12px;
}

.detail-pane {
  display: none;
  min-width: 0;
  position: fixed;
  top: 76px;
  right: 18px;
  bottom: 18px;
  z-index: 23;
  width: min(390px, calc(100vw - 36px));
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 20px;
  background: rgba(247, 248, 255, 0.96);
  box-shadow: var(--shadow-floating);
  backdrop-filter: blur(18px);
  padding: 20px 26px;
  overflow: auto;
}

.app-shell.is-detail-open .detail-pane {
  display: block;
}

.detail-pane::-webkit-scrollbar {
  width: 8px;
}

.detail-pane::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.42);
}

.detail-close-btn {
  position: sticky;
  top: 0;
  margin-left: auto;
  z-index: 2;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 8px 18px rgba(40, 60, 120, 0.08);
}

.detail-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(120, 140, 180, 0.14);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.detail-profile {
  text-align: center;
}

.detail-profile__avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  margin: 4px auto 10px;
  border: 1px solid var(--line);
}

.detail-profile h2 {
  margin: 0;
  font-size: 18px;
}

.detail-profile p {
  color: var(--muted);
  line-height: 1.55;
  margin: 8px 0;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.tag {
  border: 1px solid #cfe2ff;
  background: #eef6ff;
  color: #135aa5;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

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

.section-head h3 {
  margin: 0;
  font-size: 15px;
}

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

.quick-grid button {
  min-width: 0;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--text);
}

.quick-grid img {
  width: 22px;
  height: 22px;
}

.quick-grid span {
  font-size: 12px;
}

.context-list {
  margin: 0;
}

.context-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.context-list div:last-child {
  border-bottom: 0;
}

.context-list dt {
  color: var(--muted);
}

.context-list dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.38);
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell {
  width: min(720px, 100%);
  max-height: min(860px, calc(100dvh - 48px));
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-shell-wide {
  width: min(1120px, 100%);
}

.modal-head {
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
}

.modal-head small {
  display: block;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

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

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

.status-pill {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  font-size: 13px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: 0;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  border-color: var(--brand);
  background: var(--brand-gradient);
  color: #fff;
}

.btn-primary:hover {
  border-color: #6575ff;
  background: linear-gradient(135deg, #6171ff, #7568ff);
  color: #fff;
  box-shadow: 0 12px 24px rgba(79, 99, 255, 0.24);
}

.btn-danger {
  border-color: rgba(217, 58, 58, 0.22);
  color: var(--danger);
}

.settings-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  flex: 1;
  overflow: hidden;
}

.settings-nav {
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.settings-nav button {
  width: 100%;
  min-height: 42px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.settings-nav button.is-active {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--brand);
}

.settings-content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 91, 255, 0.48) transparent;
}

.settings-content::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.settings-content::-webkit-scrollbar-track {
  background: transparent;
}

.settings-content::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.42);
  background-clip: padding-box;
}

.settings-content::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 99, 255, 0.62);
  background-clip: padding-box;
}

.settings-view {
  display: none;
  padding: 18px;
  gap: 14px;
}

.settings-view.is-active {
  display: grid;
}

.advanced-config-card {
  border: 1px solid rgba(120, 140, 180, 0.16);
  border-radius: clamp(16px, 1.25vw, 22px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 250, 255, 0.86));
  box-shadow: 0 14px 34px rgba(79, 99, 255, 0.08);
  overflow: hidden;
}

.advanced-config-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px 10px;
}

.advanced-config-head img {
  width: 21px;
  height: 21px;
  filter: invert(43%) sepia(72%) saturate(1896%) hue-rotate(220deg) brightness(101%) contrast(101%);
}

.advanced-config-head h4 {
  margin: 0 0 2px;
  color: var(--brand);
  font-size: clamp(15px, 1.05vw, 18px);
  line-height: 1.2;
}

.advanced-config-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.advanced-setting-list {
  border: 1px solid rgba(120, 140, 180, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  margin: 0 16px 16px;
  overflow: hidden;
}

.advanced-setting-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(4.75rem, 7.25rem) minmax(12rem, 30%);
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.advanced-setting-row + .advanced-setting-row {
  border-top: 1px solid rgba(120, 140, 180, 0.14);
}

.advanced-setting-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.advanced-setting-copy strong {
  color: #101828;
  font-size: 13px;
  line-height: 1.28;
}

.advanced-setting-copy em {
  color: #8993b8;
  font-style: normal;
  font-size: 0.86em;
  font-weight: 750;
}

.advanced-setting-copy small {
  color: #6d7895;
  font-size: 11px;
  line-height: 1.3;
}

.advanced-value-pill {
  min-width: 0;
  justify-self: stretch;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(238, 240, 255, 0.95), rgba(232, 235, 255, 0.72));
  color: var(--brand);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  padding: 6px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.advanced-setting-row input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid rgba(120, 140, 180, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  box-shadow: inset 0 1px 2px rgba(40, 60, 120, 0.04);
}

.advanced-setting-row input[type="number"]:focus,
.advanced-setting-row input[type="range"]:focus-visible {
  outline: 2px solid rgba(99, 91, 255, 0.22);
  outline-offset: 2px;
  border-color: rgba(99, 91, 255, 0.50);
}

.advanced-setting-row input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--brand);
}

.advanced-setting-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(99, 91, 255, 0.82), rgba(108, 92, 255, 0.55));
}

.advanced-setting-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--brand-gradient);
  box-shadow: 0 3px 10px rgba(79, 99, 255, 0.26);
}

.advanced-setting-row--toggle {
  cursor: pointer;
}

.advanced-ios-switch {
  justify-self: end;
  position: relative;
  width: 46px;
  height: 26px;
}

.advanced-ios-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.advanced-ios-switch span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(120, 140, 180, 0.24);
  border-radius: 999px;
  background: #e7ebf4;
  box-shadow: inset 0 1px 2px rgba(31, 41, 55, 0.10);
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.advanced-ios-switch span::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 10px rgba(31, 41, 55, 0.18);
  transition: transform 180ms ease;
}

.advanced-ios-switch input:checked + span {
  border-color: rgba(79, 99, 255, 0.58);
  background: var(--brand-gradient);
  box-shadow: 0 8px 18px rgba(79, 99, 255, 0.18);
}

.advanced-ios-switch input:checked + span::before {
  transform: translateX(20px);
}

.panel-title h3 {
  margin: 0 0 4px;
}

.panel-title p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.switch-row input {
  width: 18px;
  height: 18px;
}

.knowledge-workbench {
  min-height: 0;
  height: min(620px, calc(100dvh - 190px));
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.kb-sidebar {
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kb-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.kb-list,
.kb-file-list,
.kb-chunk-list,
.member-picker,
.memory-result-list,
.memory-archive-list,
.memory-node-detail {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #b8c4d0 transparent;
}

.kb-list::-webkit-scrollbar,
.kb-file-list::-webkit-scrollbar,
.kb-chunk-list::-webkit-scrollbar,
.member-picker::-webkit-scrollbar,
.memory-result-list::-webkit-scrollbar,
.memory-archive-list::-webkit-scrollbar,
.memory-node-detail::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.kb-list::-webkit-scrollbar-thumb,
.kb-file-list::-webkit-scrollbar-thumb,
.kb-chunk-list::-webkit-scrollbar-thumb,
.member-picker::-webkit-scrollbar-thumb,
.memory-result-list::-webkit-scrollbar-thumb,
.memory-archive-list::-webkit-scrollbar-thumb,
.memory-node-detail::-webkit-scrollbar-thumb {
  background: #b8c4d0;
  border-radius: 999px;
}

.kb-list {
  min-height: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.kb-item,
.memory-result-item,
.memory-archive-item {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 100%;
  text-align: left;
  padding: 11px 12px;
}

.kb-item:hover,
.kb-item.is-active,
.memory-result-item:hover,
.memory-archive-item:hover {
  background: var(--surface-hover);
}

.kb-item.is-active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.kb-item strong,
.kb-item small,
.memory-result-item strong,
.memory-result-item small,
.memory-archive-item strong,
.memory-archive-item small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kb-item small,
.memory-result-item small,
.memory-archive-item small {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.kb-main {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.kb-detail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

.kb-empty-state {
  min-height: 100%;
  border: 1px dashed rgba(120, 140, 180, 0.26);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(79, 99, 255, 0.05), rgba(255, 255, 255, 0.92));
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.kb-empty-state span,
.kb-detail-head span {
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.kb-detail-head {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 26px rgba(40, 60, 120, 0.08);
}

.kb-detail-head h3,
.kb-detail-head p {
  margin: 0;
}

.kb-detail-head h3 {
  color: var(--text);
  font-size: 18px;
}

.kb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kb-icon-btn {
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
}

.kb-icon-btn img {
  width: 20px;
  height: 20px;
}

.kb-icon-btn.btn-primary img {
  filter: brightness(0) invert(1);
}

.kb-icon-btn.btn-primary:hover {
  background: linear-gradient(135deg, #6171ff, #7568ff);
  color: #fff;
}

.kb-icon-btn.btn-primary:hover img {
  filter: brightness(0) invert(1);
}

.kb-icon-btn-danger img {
  filter: invert(34%) sepia(82%) saturate(1394%) hue-rotate(331deg) brightness(88%) contrast(92%);
}

.btn-soft {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--line);
  color: var(--muted);
}

.btn-soft:hover {
  background: var(--surface-hover);
}

.kb-status {
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 12px;
  background: rgba(248, 250, 255, 0.82);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 13px;
}

.kb-status[data-kind="ok"] {
  color: #0b7a5f;
  background: rgba(0, 168, 132, 0.08);
}

.kb-status[data-kind="warn"] {
  color: var(--warning);
  background: rgba(183, 121, 31, 0.1);
}

.kb-upload-console {
  min-width: 0;
}

#kb-upload-status {
  display: none !important;
}

.kb-upload-card {
  width: 100%;
  min-height: 92px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  cursor: pointer;
}

.kb-upload-card:hover {
  border-color: var(--brand);
  background: #f8fbff;
}

.kb-upload-card span {
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.kb-upload-card strong {
  font-size: 16px;
}

.kb-upload-card small {
  color: var(--muted);
}

.kb-management-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: hidden;
}

.kb-files-panel,
.kb-chunks-panel,
.memory-node-card,
.memory-side-card {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.kb-panel-label {
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kb-panel-label span {
  color: var(--muted);
  font-size: 12px;
}

.kb-panel-label strong {
  color: var(--brand);
  font-size: 11px;
}

.kb-file-list,
.kb-chunk-list {
  min-height: 0;
  flex: 1;
}

.file-row,
.chunk-row {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.file-row {
  width: 100%;
  min-height: 68px;
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.file-row:hover,
.file-row.is-active {
  background: #eef6ff;
}

.file-row.is-active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.file-row strong,
.chunk-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.file-row small,
.chunk-row small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.45;
}

.kb-empty-line {
  padding: 18px 14px;
  color: var(--muted);
  line-height: 1.6;
}

.group-editor {
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
}

.group-create-search {
  min-height: 76px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  display: grid;
  grid-template-columns: minmax(110px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.group-selected-strip {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.group-selected-strip img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  margin-left: -8px;
}

.group-selected-strip img:first-child {
  margin-left: 0;
}

.group-selected-strip span {
  color: var(--muted);
  font-size: 14px;
}

.group-create-search input {
  min-height: 48px;
  border-color: transparent;
  font-size: 20px;
}

.group-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 14px;
}

.group-list-head strong {
  color: var(--text);
  font-size: 18px;
}

.member-picker {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.member-item {
  width: 100%;
  min-height: 70px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: 34px 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.member-item:hover {
  background: var(--surface-soft);
}

.member-check {
  width: 26px;
  height: 26px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.member-item.is-selected .member-check {
  border-color: #1598f4;
  background: #1598f4;
}

.member-item.is-selected .member-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.member-item img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

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

.member-text strong,
.member-text small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.member-text strong {
  font-size: 16px;
  font-weight: 500;
}

.member-text small {
  color: var(--muted);
  margin-top: 4px;
}

.member-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.group-info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 22;
  background: rgba(15, 23, 42, 0.16);
}

.group-info-panel {
  position: fixed;
  top: 76px;
  right: 18px;
  bottom: 18px;
  z-index: 23;
  width: min(390px, calc(100vw - 36px));
  pointer-events: none;
}

.group-info-shell {
  height: 100%;
  pointer-events: auto;
  overflow: auto;
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 20px;
  background: rgba(247, 248, 250, 0.96);
  box-shadow: 0 22px 52px rgba(25, 34, 45, 0.18);
  backdrop-filter: blur(18px);
  padding: 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.group-info-shell::-webkit-scrollbar,
.group-info-member-list::-webkit-scrollbar {
  width: 8px;
}

.group-info-shell::-webkit-scrollbar-thumb,
.group-info-member-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #b8c4d0;
}

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

.group-info-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.group-link-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 13px;
}

.group-link-btn::after {
  content: "›";
  margin-left: 4px;
}

.group-info-card,
.group-info-section {
  border: 1px solid rgba(120, 140, 180, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
}

.group-info-card {
  padding: 16px;
}

.group-info-member-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px 12px;
}

.group-info-member {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0;
}

.group-info-member img,
.group-info-symbol {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.group-info-member img {
  object-fit: cover;
  border: 1px solid var(--line);
}

.group-info-symbol {
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: #f2f3f5;
  color: var(--text);
  font-size: 26px;
  font-weight: 300;
}

.group-info-member:hover .group-info-symbol,
.group-info-member:hover img {
  box-shadow: 0 8px 18px rgba(22, 119, 255, 0.12);
}

.group-info-member span:last-child {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  text-align: center;
}

.group-info-member-editor {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}

.group-info-member-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.group-info-member-row {
  width: 100%;
  min-height: 62px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 28px 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  text-align: left;
}

.group-info-member-row:last-child {
  border-bottom: 0;
}

.group-info-member-row:hover {
  background: var(--surface-soft);
}

.group-info-member-row.is-selected .member-check {
  border-color: #1598f4;
  background: #1598f4;
}

.group-info-member-row.is-selected .member-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.group-info-member-row img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.group-info-member-row strong,
.group-info-member-row small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.group-info-member-row small {
  color: var(--muted);
  margin-top: 3px;
}

.group-info-editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.group-info-section h3 {
  margin: 0;
  padding: 14px 16px 4px;
  font-size: 15px;
  font-weight: 650;
}

.toggle-row,
.group-setting-row {
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  display: grid;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
}

.toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.toggle-row:last-child,
.group-setting-row:last-child {
  border-bottom: 0;
}

.toggle-row span,
.group-setting-row span {
  color: var(--text);
  font-size: 15px;
}

.toggle-row input {
  appearance: none;
  width: 38px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: #d7dce2;
  padding: 2px;
  transition: background 150ms ease;
}

.toggle-row input::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
  transition: transform 150ms ease;
}

.toggle-row input:checked {
  background: var(--brand-gradient);
}

.toggle-row input:checked::before {
  transform: translateX(16px);
}

.group-setting-row {
  grid-template-columns: minmax(0, 1fr) 72px auto;
}

.group-setting-row input {
  height: 32px;
  padding: 5px 8px;
  text-align: center;
}

.group-setting-slider {
  grid-template-columns: minmax(0, 1fr) minmax(72px, 120px) auto;
}

.group-setting-slider input[type="range"] {
  padding: 0;
  accent-color: var(--brand);
}

.group-setting-row small {
  color: var(--muted);
  white-space: nowrap;
}

.group-setting-button {
  width: 100%;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  background: transparent;
  text-align: left;
  grid-template-columns: minmax(0, 1fr) auto;
}

.group-setting-button:hover {
  background: var(--surface-soft);
}

.group-leave-btn {
  margin-top: auto;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #ff4d4f;
  font-weight: 650;
}

.group-leave-btn:hover {
  background: #fff1f0;
}

.group-create-actions {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.group-create-actions .btn {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.memory-shell {
  width: min(1180px, 100%);
  height: min(860px, calc(100dvh - 48px));
}

.memory-layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
  position: relative;
}

.memory-command-panel {
  min-width: 0;
  min-height: 0;
  background: var(--surface-soft);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.memory-command-panel {
  border-right: 1px solid var(--line);
}

.memory-search-console {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.memory-panel-kicker {
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.memory-search-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.memory-search-submit {
  background: var(--brand-gradient);
  box-shadow: 0 12px 24px rgba(79, 99, 255, 0.18);
}

.memory-search-submit:hover {
  background: linear-gradient(135deg, #6171ff, #7568ff);
  box-shadow: 0 12px 24px rgba(79, 99, 255, 0.24);
}

.memory-search-submit img {
  filter: brightness(0) invert(1);
}

.memory-search-submit:hover img {
  filter: brightness(0) invert(1);
}

.memory-node-card {
  flex: 1;
}

.memory-node-card .section-head,
.memory-side-card .section-head {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  margin: 0;
  padding: 0 12px;
}

.memory-node-detail {
  min-height: 0;
  flex: 1;
  padding: 12px;
  color: var(--muted);
}

.memory-graph-wrap {
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    linear-gradient(rgba(22, 119, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 119, 255, 0.05) 1px, transparent 1px),
    #ffffff;
  background-size: 32px 32px;
}

#memory-graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.memory-graph-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
}

.memory-side-card {
  flex: 1;
}

.memory-result-panel,
.memory-archive-popover,
.memory-settings-popover {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  width: min(380px, calc(100% - 28px));
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 46px rgba(40, 60, 120, 0.16);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memory-settings-popover {
  bottom: auto;
  max-height: min(560px, calc(100% - 28px));
  padding-bottom: 12px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #b8c4d0 transparent;
}

.memory-settings-popover::-webkit-scrollbar {
  width: 8px;
}

.memory-settings-popover::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #b8c4d0;
}

.memory-result-head {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 12px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.memory-mini-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 18px;
}

.memory-mini-close img {
  width: 17px;
  height: 17px;
}

.memory-mini-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.memory-result-list,
.memory-archive-list {
  min-height: 0;
  flex: 1;
}

.memory-result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--brand);
  font-size: 12px;
}

.memory-archive-toolbar,
.memory-settings-popover .memory-setting-field,
.memory-settings-popover .memory-toggle-row {
  padding: 12px;
}

.memory-archive-toolbar {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.memory-archive-search-field {
  gap: 6px;
}

.memory-archive-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.memory-archive-filter button {
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.memory-archive-filter button.is-active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.memory-archive-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.memory-archive-body {
  min-width: 0;
}

.memory-archive-text {
  color: var(--text);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.memory-archive-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.memory-archive-meta span {
  border: 1px solid rgba(120, 140, 180, 0.18);
  border-radius: 999px;
  background: rgba(248, 250, 255, 0.92);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 12px;
}

.memory-archive-item strong,
.memory-archive-item small {
  grid-column: 1;
}

.memory-archive-item .btn,
.memory-archive-item .memory-danger-icon {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.memory-settings-popover textarea {
  min-height: 120px;
  resize: vertical;
}

.memory-settings-popover > .btn {
  margin: 0 12px;
}

.memory-edge-row {
  border-top: 1px solid var(--line);
  padding: 8px 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memory-edge-row span {
  overflow-wrap: anywhere;
}

.memory-edge-pill {
  border-top: 1px solid var(--line);
  padding: 8px 0;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memory-edge-pill-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.memory-edge-delete,
.memory-danger-icon {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 77, 79, 0.22);
  border-radius: 14px;
  background: rgba(255, 241, 240, 0.82);
  color: var(--danger);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.memory-edge-delete:hover,
.memory-danger-icon:hover {
  border-color: rgba(255, 77, 79, 0.38);
  background: rgba(255, 226, 224, 0.94);
}

.memory-edge-delete img,
.memory-danger-icon img {
  width: 18px;
  height: 18px;
  filter: invert(36%) sepia(75%) saturate(2388%) hue-rotate(337deg) brightness(94%) contrast(96%);
}

.memory-settings-popover .memory-toggle-row {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
}

.memory-settings-popover .memory-toggle-row input[type="checkbox"] {
  appearance: none;
  width: 48px;
  height: 28px;
  border: 1px solid rgba(120, 140, 180, 0.24);
  border-radius: 999px;
  background: #e7ebf4;
  box-shadow: inset 0 1px 2px rgba(31, 41, 55, 0.10);
  position: relative;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.memory-settings-popover .memory-toggle-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(31, 41, 55, 0.18);
  transition: transform 180ms ease;
}

.memory-settings-popover .memory-toggle-row input[type="checkbox"]:checked {
  border-color: rgba(79, 99, 255, 0.58);
  background: var(--brand-gradient);
  box-shadow: 0 8px 18px rgba(79, 99, 255, 0.18);
}

.memory-settings-popover .memory-toggle-row input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.about-panel {
  text-align: center;
  max-width: 520px;
  margin: 24px auto;
  color: var(--muted);
  line-height: 1.6;
}

.about-panel img {
  width: 92px;
  height: 92px;
  margin: 0 auto 12px;
}

.about-panel h3 {
  color: var(--text);
  margin: 0 0 8px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: var(--rail-width) 340px minmax(0, 1fr);
  }

  .app-shell.is-detail-open {
    grid-template-columns: var(--rail-width) 340px minmax(0, 1fr);
  }

  .detail-pane,
  .app-shell.is-detail-open .detail-pane {
    display: none;
  }

  .memory-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .app-shell.is-private-chat.is-detail-open .detail-pane {
    display: block;
    position: fixed;
    top: 76px;
    right: 16px;
    bottom: 16px;
    z-index: 23;
    width: min(390px, calc(100vw - var(--rail-width) - 48px));
  }
}

@media (max-width: 760px) {
  html,
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.is-detail-open {
    grid-template-columns: 1fr;
  }

  .detail-pane,
  .app-shell.is-detail-open .detail-pane {
    display: none;
  }

  .rail {
    position: fixed;
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 10;
    height: 64px;
    border: 1px solid rgba(120, 140, 180, 0.18);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-floating);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    gap: 4px;
    padding: 8px;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .app-shell.is-chat-open .rail {
    pointer-events: none;
    opacity: 0;
    transform: translateY(calc(100% + 24px));
  }

  .rail-brand {
    display: none;
  }

  .rail-btn {
    width: 48px;
    height: 48px;
    border-radius: 17px;
    box-shadow: none;
  }

  .rail-btn.is-active {
    background: var(--brand-gradient);
    box-shadow: 0 12px 24px rgba(79, 99, 255, 0.28);
  }

  .rail-btn.is-active img {
    filter: brightness(0) invert(1);
  }

  .conversation-list,
  .chat-pane {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 100dvh;
  }

  .conversation-list {
    border-right: 0;
    transform: translateX(0);
    transition: transform 180ms ease;
    z-index: 2;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .chat-pane {
    transform: translateX(100%);
    transition: transform 180ms ease;
    z-index: 3;
  }

  .app-shell.is-chat-open .conversation-list {
    transform: translateX(-18%);
  }

  .app-shell.is-chat-open .chat-pane {
    transform: translateX(0);
  }

  .mobile-back {
    display: inline-grid;
  }

  .chat-head {
    padding: 0 8px;
    gap: 8px;
  }

  .chat-head__actions {
    gap: 0;
  }

  .chat-head__actions .icon-btn {
    width: 34px;
    height: 34px;
  }

  .roundtable-error-popover {
    top: 64px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: min(52dvh, 420px);
  }

  .message-list {
    padding: 16px 10px clamp(8.25rem, 20vh, 10rem);
  }

  .message-row {
    max-width: 100%;
  }

  .message-content {
    max-width: min(76vw, 520px);
  }

  .composer {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    border-radius: 18px;
    padding: 8px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mention-popover {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(100% - 2px);
  }

  .composer-tools {
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  .send-btn {
    min-width: 72px;
    padding: 0 12px;
  }

  .send-btn span {
    display: none;
  }

  .app-shell.is-private-chat.is-detail-open .detail-pane {
    display: block;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(92vw, 420px);
    border-radius: 20px 0 0 20px;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .modal {
    padding: 0;
    place-items: stretch;
  }

  .modal-shell,
  .modal-shell-wide {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .form-grid,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .form-grid {
    padding: 14px;
  }

  .settings-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    overflow-x: auto;
  }

  .settings-nav button {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .advanced-config-head {
    padding: 12px;
  }

  .advanced-setting-list {
    margin: 0 10px 10px;
  }

  .advanced-setting-row {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 11px;
  }

  .advanced-value-pill {
    justify-self: start;
    min-width: 4.8rem;
  }

  .advanced-ios-switch {
    justify-self: start;
  }

  .knowledge-workbench {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .kb-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 230px;
  }

  .kb-list {
    min-height: 130px;
  }

  .kb-main {
    overflow: visible;
  }

  .kb-management-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .kb-files-panel,
  .kb-chunks-panel {
    min-height: 180px;
  }

  .group-editor {
    height: calc(100dvh - 68px);
    padding: 14px;
  }

  .group-create-search {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .group-create-search input {
    font-size: 18px;
  }

  .group-info-backdrop {
    background: rgba(15, 23, 42, 0.22);
  }

  .group-info-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: min(92vw, 420px);
  }

  .group-info-shell {
    border-radius: 20px 0 0 20px;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  }

  .group-info-member-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 10px;
  }

  .group-setting-row {
    grid-template-columns: minmax(0, 1fr) 66px auto;
  }

  .memory-shell {
    height: 100dvh;
  }

  .memory-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .memory-command-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
    max-height: 210px;
    overflow: auto;
  }

  .memory-result-panel,
  .memory-archive-popover,
  .memory-settings-popover {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: min(54dvh, 420px);
  }

  .memory-settings-popover {
    top: 10px;
    bottom: auto;
    max-height: calc(100% - 20px);
  }

  .memory-graph-hint {
    left: 10px;
    right: 10px;
    text-align: center;
  }

  .memory-search-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  #memory-node-panel.modal {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    place-items: stretch;
  }

  #memory-node-panel .memory-shell {
    width: 100%;
    height: calc(100dvh - 16px);
    max-height: none;
    border-radius: clamp(18px, 5vw, 24px);
    overflow: hidden;
  }

  #memory-node-panel .modal-head {
    min-height: 58px;
    padding: 8px 10px 8px 14px;
    gap: 8px;
  }

  #memory-node-panel .modal-head small,
  #memory-node-panel #memory-node-stats {
    display: none;
  }

  #memory-node-panel .modal-head h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.15;
  }

  #memory-node-panel .modal-head-actions {
    gap: 6px;
  }

  #memory-node-panel .modal-head-actions .icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 13px;
  }

  #memory-node-panel .modal-head-actions .icon-btn img {
    width: 18px;
    height: 18px;
  }

  #memory-node-panel .memory-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    position: relative;
  }

  #memory-node-panel .memory-command-panel {
    max-height: 178px;
    padding: 10px 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 250, 255, 0.64);
  }

  #memory-node-panel .memory-node-card {
    min-height: 150px;
    flex: 1 1 auto;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 12px 28px rgba(40, 60, 120, 0.08);
  }

  #memory-node-panel .memory-node-card .section-head {
    min-height: 36px;
    padding: 0 12px;
    background: rgba(248, 250, 255, 0.82);
  }

  #memory-node-panel .memory-node-card .section-head h3 {
    font-size: 13px;
  }

  #memory-node-panel .memory-node-detail {
    min-height: 86px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
  }

  #memory-node-panel .memory-node-detail-title {
    color: var(--text);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
  }

  #memory-node-panel .memory-empty-line {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
  }

  #memory-node-panel .memory-edge-pill {
    padding: 7px 0;
    font-size: 12px;
    line-height: 1.45;
  }

  #memory-node-panel .memory-edge-delete {
    width: 32px;
    height: 32px;
    border-radius: 12px;
  }

  #memory-node-panel .memory-search-console {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 5;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  #memory-node-panel .memory-search-console .memory-panel-kicker {
    display: none;
  }

  #memory-node-panel .memory-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    pointer-events: auto;
  }

  #memory-node-panel .memory-search-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    border: 1px solid rgba(99, 91, 255, 0.28);
    border-radius: 999px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 255, 0.92)),
      rgba(255, 255, 255, 0.86);
    box-shadow: 0 12px 26px rgba(79, 99, 255, 0.18);
    -webkit-tap-highlight-color: transparent;
  }

  #memory-node-panel .memory-search-toggle img,
  #memory-node-panel .memory-search-submit img {
    width: 24px;
    height: 24px;
  }

  #memory-node-panel .memory-search-row input,
  #memory-node-panel .memory-search-submit {
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
    transition:
      opacity 180ms ease,
      transform 180ms ease;
  }

  #memory-node-panel .memory-search-console.is-compact-open .memory-search-row input,
  #memory-node-panel .memory-search-console.is-compact-open .memory-search-submit {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  #memory-node-panel .memory-search-row input {
    width: min(220px, calc(100vw - 142px));
    min-height: 46px;
    border-radius: 999px;
    padding: 8px 15px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 24px rgba(79, 99, 255, 0.12);
  }

  #memory-node-panel .memory-search-submit {
    display: grid;
    place-items: center;
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    border-radius: 999px;
    box-shadow: 0 12px 24px rgba(79, 99, 255, 0.20);
  }

  #memory-node-panel .memory-graph-wrap {
    min-height: 0;
  }

  #memory-node-panel .memory-graph-hint {
    left: auto;
    right: 12px;
    bottom: 10px;
    width: min(300px, calc(100vw - 100px));
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #memory-node-panel .memory-result-panel,
  #memory-node-panel .memory-settings-popover {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 92px;
    width: auto;
    max-height: min(48dvh, 340px);
    border-radius: 18px;
  }

  #memory-node-panel .memory-archive-popover {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 92px;
    width: auto;
    max-height: min(60dvh, 500px);
    border-radius: 18px 18px 16px 16px;
  }

  #memory-node-panel .memory-archive-toolbar {
    gap: 8px;
    padding: 10px;
  }

  #memory-node-panel .memory-archive-search-field {
    gap: 4px;
    font-size: 11px;
  }

  #memory-node-panel .memory-archive-search-field input,
  #memory-node-panel #memory-setting-retention,
  #memory-node-panel #memory-setting-keywords {
    min-height: 38px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 16px;
  }

  #memory-node-panel #memory-setting-keywords {
    min-height: 76px;
    max-height: min(22dvh, 132px);
  }

  #memory-node-panel .memory-archive-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #memory-node-panel .memory-archive-filter button {
    min-height: 34px;
    padding: 5px 4px;
    font-size: 11px;
  }

  #memory-node-panel .memory-result-item,
  #memory-node-panel .memory-archive-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 9px;
  }

  #memory-node-panel .memory-archive-text {
    font-size: 12px;
    line-height: 1.45;
  }

  #memory-node-panel .memory-archive-meta {
    gap: 4px;
    margin-top: 5px;
  }

  #memory-node-panel .memory-archive-meta span {
    padding: 3px 6px;
    font-size: 10px;
  }

  #memory-node-panel .memory-result-item .memory-danger-icon,
  #memory-node-panel .memory-archive-item .memory-danger-icon {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
    width: 100%;
  }

  #memory-node-panel #memory-node-settings-save {
    width: calc(100% - 24px);
  }
}
