:root {
  color-scheme: dark;
  --bg: #111522;
  --bg-deep: #0c101a;
  --panel: rgba(20, 25, 39, 0.94);
  --panel-soft: rgba(30, 37, 55, 0.72);
  --panel-solid: #1a2030;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f7f1eb;
  --muted: #9da6b7;
  --muted-soft: #737d90;
  --accent: #e6aa68;
  --accent-bright: #f4bd79;
  --accent-soft: rgba(230, 170, 104, 0.14);
  --accent-faint: rgba(230, 170, 104, 0.07);
  --danger: #dc7e7e;
  --success: #7ed6ae;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
  --sidebar-width: 284px;
  --font-xs: 11px;
  --font-sm: 12px;
  --font-md: 14px;
  --font-chat: 15px;
  --font-lg: 18px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --wechat-bubble-user: #95ec69;
  --wechat-page: #ededed;
  --wechat-bar: #f7f7f7;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  overflow: hidden;
  color: var(--text);
  background: var(--bg-deep);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: var(--font-md);
  -webkit-font-smoothing: antialiased;
}

.cloud-auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(237, 237, 237, 0.86);
  backdrop-filter: blur(18px);
}

.cloud-auth-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 22px;
  color: #191919;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}

.cloud-auth-card h1 {
  margin: 6px 0 8px;
  font-size: 26px;
}

.cloud-auth-copy {
  margin: 0 0 20px;
  color: #6f6f6f;
  line-height: 1.7;
}

.cloud-auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.cloud-auth-actions button {
  flex: 1;
}

.onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 940;
  display: grid;
  padding: 28px;
  place-items: center;
  background: rgba(237, 237, 237, 0.82);
  backdrop-filter: blur(18px);
}

.onboarding-card {
  width: min(820px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  padding: 28px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 24px;
  color: #191919;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.16);
}

.onboarding-kicker {
  color: #07c160;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.onboarding-card h1 {
  margin: 8px 0 8px;
  font-size: 28px;
  line-height: 1.25;
}

.onboarding-copy {
  max-width: 680px;
  margin: 0 0 20px;
  color: #6f6f6f;
  line-height: 1.8;
}

.onboarding-card .field {
  padding: 0;
  background: transparent;
}

.onboarding-brief textarea {
  min-height: 138px;
}

.onboarding-options {
  display: grid;
  gap: 12px;
  grid-template-columns: 1.3fr 0.8fr 0.8fr;
}

.onboarding-actions {
  margin-top: 12px;
}

.onboarding-draft {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
.conversation-item {
  -webkit-tap-highlight-color: transparent;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(10px);
  opacity: 0.68;
}

.ambient-one {
  top: -180px;
  right: 8%;
  width: 480px;
  height: 360px;
  background: radial-gradient(circle, rgba(108, 83, 142, 0.2), transparent 68%);
}

.ambient-two {
  bottom: -220px;
  left: 25%;
  width: 560px;
  height: 420px;
  background: radial-gradient(circle, rgba(187, 119, 75, 0.13), transparent 68%);
}

.app-shell {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-direction: column;
  padding: 19px 14px 16px;
  border-right: 1px solid var(--line);
  background: rgba(12, 16, 26, 0.74);
  backdrop-filter: blur(24px);
}

.sidebar-top,
.brand,
.chat-header,
.chat-header-left,
.character-header,
.character-name-row,
.header-actions,
.composer-actions,
.settings-header,
.field-row,
.switch-field,
.settings-footer {
  display: flex;
  align-items: center;
}

.sidebar-top,
.chat-header,
.settings-header,
.settings-footer {
  justify-content: space-between;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(230, 170, 104, 0.42);
  border-radius: 13px;
  place-items: center;
  color: var(--accent-bright);
  background: linear-gradient(145deg, rgba(230, 170, 104, 0.2), rgba(230, 170, 104, 0.05));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.13);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 24px;
}

.brand-name,
.brand-caption,
.sidebar-section-heading,
.character-title h1,
.character-title p,
.privacy-note,
.eyebrow,
.settings-intro p,
.switch-field p,
.message-meta,
.empty-state p {
  margin: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-caption,
.eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.19em;
}

.new-chat-button,
.sidebar-link,
.settings-button,
.primary-button,
.starter,
.conversation-delete,
.icon-button,
.send-button,
.stop-button,
.character-header {
  border: 0;
  cursor: pointer;
}

.new-chat-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 26px;
  padding: 12px 14px;
  border: 1px solid rgba(230, 170, 104, 0.25);
  border-radius: 12px;
  color: var(--accent-bright);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 600;
  transition: 160ms ease;
}

.new-chat-button:hover {
  border-color: rgba(230, 170, 104, 0.5);
  background: rgba(230, 170, 104, 0.2);
}

.new-chat-button svg,
.sidebar-link svg,
.settings-button svg,
.icon-button svg,
.attach-button svg,
.send-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 29px 4px 9px;
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.conversation-count {
  display: grid;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 10px;
  letter-spacing: 0;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.conversation-list::-webkit-scrollbar,
.messages-scroll::-webkit-scrollbar {
  width: 5px;
}

.conversation-list::-webkit-scrollbar-thumb,
.messages-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.conversation-empty {
  padding: 18px 5px;
  color: var(--muted-soft);
  font-size: var(--font-sm);
  line-height: 1.8;
}

.conversation-item {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 10px 31px 10px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition: 140ms ease;
}

.conversation-item:hover,
.conversation-item.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
}

.conversation-item.active {
  border-color: var(--line);
}

.conversation-item-icon {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  border-radius: 999px;
}

.conversation-item.active .conversation-item-icon {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(230, 170, 104, 0.56);
}

.conversation-item-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.conversation-item-title {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item-character {
  overflow: hidden;
  color: var(--muted-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item.active .conversation-item-character {
  color: var(--muted);
}

.conversation-delete {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  place-items: center;
  opacity: 0;
  color: var(--muted-soft);
  background: transparent;
  transform: translateY(-50%);
  transition: 140ms ease;
}

.conversation-item:hover .conversation-delete,
.conversation-item.active .conversation-delete {
  opacity: 1;
}

.conversation-delete:hover {
  color: var(--danger);
  background: rgba(220, 126, 126, 0.12);
}

.conversation-delete svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.sidebar-footer {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.sidebar-account div {
  min-width: 0;
}

.sidebar-account span,
.sidebar-account strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account span {
  color: var(--muted-soft);
  font-size: 10px;
}

.sidebar-account strong {
  margin-top: 2px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.sidebar-account button {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 11px;
  transition: 140ms ease;
}

.sidebar-account button:hover {
  color: var(--danger);
  background: rgba(220, 126, 126, 0.12);
}

.sidebar-link {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 7px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  text-align: left;
  transition: 140ms ease;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-link svg {
  width: 16px;
  height: 16px;
}

.chat-panel {
  position: relative;
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  background: rgba(17, 21, 34, 0.72);
}

.chat-header {
  z-index: 4;
  height: 72px;
  min-height: 72px;
  padding: 0 25px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 21, 34, 0.76);
  backdrop-filter: blur(20px);
}

.chat-header-left,
.header-actions {
  gap: 12px;
}

.character-header {
  gap: 11px;
  padding: 0;
  background: transparent;
  text-align: left;
}

.conversation-character-button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
  transition: 140ms ease;
}

.conversation-character-button:hover {
  border-color: var(--line-strong);
  color: var(--accent-bright);
  background: var(--accent-faint);
}

.avatar {
  display: grid;
  overflow: hidden;
  border-radius: 50%;
  place-items: center;
  color: #2d2018;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 25%),
    linear-gradient(145deg, #efc07c, #a86e4f);
  font-family: "DM Serif Display", "Noto Sans SC", serif;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(230, 170, 104, 0.13);
}

.avatar-character {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.character-name-row {
  gap: 7px;
}

.character-title h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.character-title p {
  max-width: 380px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 9px rgba(126, 214, 174, 0.7);
}

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

.icon-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.settings-button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  transition: 150ms ease;
}

.settings-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
}

.settings-button svg {
  width: 16px;
  height: 16px;
}

.messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.messages {
  display: flex;
  width: min(100%, 920px);
  min-height: 100%;
  flex-direction: column;
  gap: 24px;
  margin: 0 auto;
  padding: 32px 30px 28px;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  animation: message-in 180ms ease-out;
}

.message.no-entry-animation {
  animation: none;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message .avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  margin-top: 2px;
  font-size: 12px;
}

.message.user .avatar {
  color: #e3e9f2;
  background: linear-gradient(145deg, #566780, #30394e);
  box-shadow: 0 0 0 2px rgba(135, 155, 188, 0.14);
}

.message-content {
  display: flex;
  max-width: min(75%, 680px);
  flex-direction: column;
  gap: 5px;
}

.message.user .message-content {
  align-items: flex-end;
}

.message-bubble-stack {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.message.user .message-bubble-stack {
  align-items: flex-end;
}

.message-meta {
  color: var(--muted-soft);
  font-size: 10px;
}

.auto-badge {
  padding: 1px 4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent-bright);
  font-size: 8px;
  font-weight: 600;
  vertical-align: middle;
}

.message-bubble {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 4px 15px 15px;
  color: #e9ebef;
  background: rgba(35, 42, 59, 0.8);
  font-size: var(--font-chat);
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.user .message-bubble {
  border-color: rgba(230, 170, 104, 0.23);
  border-radius: 15px 4px 15px 15px;
  color: #f6eee5;
  background: rgba(129, 86, 57, 0.53);
}

.message.error .message-bubble {
  border-color: rgba(220, 126, 126, 0.27);
  color: #f2c5c5;
  background: rgba(122, 55, 63, 0.27);
}

.message-attachments {
  display: flex;
  max-width: 320px;
  flex-direction: column;
  gap: 7px;
}

.message.user .message-attachments {
  align-items: flex-end;
}

.message-image-wrap {
  display: flex;
  max-width: 100%;
  flex-direction: column;
  gap: 5px;
}

.message-image-card {
  position: relative;
  overflow: hidden;
  width: min(320px, 62vw);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.message-image-card img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}

.message-image-card span {
  display: block;
  padding: 7px 9px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-summary {
  max-width: min(320px, 62vw);
  margin: 0;
  color: var(--muted-soft);
  font-size: 11px;
  line-height: 1.5;
}

.image-policy-actions {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.image-policy-actions button {
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  color: var(--muted-soft);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.image-policy-actions button.active {
  color: #2f2118;
  background: var(--accent);
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 1px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-dot 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: 140ms;
}

.typing i:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.empty-state {
  display: flex;
  max-width: 610px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: auto;
  padding: 54px 0 70px;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 78px;
  height: 78px;
  margin-bottom: 22px;
  border: 1px solid rgba(230, 170, 104, 0.27);
  border-radius: 27px;
  place-items: center;
  color: var(--accent-bright);
  background:
    radial-gradient(circle, rgba(230, 170, 104, 0.18), rgba(230, 170, 104, 0.04) 63%),
    rgba(255, 255, 255, 0.01);
  box-shadow: 0 0 50px rgba(230, 170, 104, 0.08);
  font-family: "DM Serif Display", "Noto Sans SC", serif;
  font-size: 36px;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-family: "DM Serif Display", "Noto Sans SC", serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.empty-state p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.starter-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.starter {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
  transition: 150ms ease;
}

.starter:hover {
  border-color: rgba(230, 170, 104, 0.28);
  color: var(--accent-bright);
  background: var(--accent-faint);
}

.composer-wrap {
  position: relative;
  z-index: 4;
  padding: 0 24px 14px;
  background: linear-gradient(transparent, rgba(17, 21, 34, 0.96) 22%);
}

.branch-recovery {
  display: flex;
  width: min(100%, 860px);
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto 8px;
  padding: 9px 11px 9px 13px;
  border: 1px solid rgba(230, 170, 104, 0.24);
  border-radius: 11px;
  background: rgba(230, 170, 104, 0.1);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.09);
}

.branch-recovery div {
  min-width: 0;
}

.branch-recovery-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.branch-recovery strong,
.branch-recovery span {
  display: block;
}

.branch-recovery strong {
  color: var(--accent-bright);
  font-size: 11px;
}

.branch-recovery span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-recovery button {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid rgba(230, 170, 104, 0.26);
  border-radius: 7px;
  color: var(--accent-bright);
  background: rgba(230, 170, 104, 0.08);
  cursor: pointer;
  font-size: 11px;
  transition: 150ms ease;
}

.branch-recovery button:hover {
  background: rgba(230, 170, 104, 0.18);
}

.branch-recovery #discardBranchButton {
  color: var(--muted);
}

.pending-attachments {
  display: flex;
  width: min(100%, 860px);
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 auto 8px;
}

.pending-attachment {
  display: inline-flex;
  max-width: min(220px, 100%);
  align-items: center;
  gap: 7px;
  padding: 5px 6px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(29, 35, 51, 0.92);
}

.pending-attachment img {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
}

.pending-attachment span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-attachment button {
  display: grid;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  place-items: center;
  color: var(--muted-soft);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.composer {
  display: flex;
  width: min(100%, 860px);
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  padding: 7px 8px 7px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(29, 35, 51, 0.93);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
  transition: 150ms ease;
}

.attach-button {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  transition: 150ms ease;
}

.attach-button:hover {
  color: var(--accent-bright);
  border-color: rgba(230, 170, 104, 0.34);
  background: rgba(230, 170, 104, 0.08);
}

.attach-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.composer:focus-within {
  border-color: rgba(230, 170, 104, 0.38);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(230, 170, 104, 0.06);
}

#messageInput {
  display: block;
  min-height: 26px;
  max-height: 160px;
  flex: 1;
  padding: 0;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 26px;
}

#messageInput::placeholder {
  color: var(--muted-soft);
}

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

.composer-hint {
  padding-right: 3px;
  color: var(--muted-soft);
  font-size: var(--font-xs);
}

.token-count {
  display: inline-flex;
  height: 22px;
  align-items: center;
  gap: 5px;
  padding: 0 5px;
  border: 0;
  border-radius: 999px;
  color: var(--muted-soft);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
  transition: 140ms ease;
}

.token-count:hover,
.token-count[aria-expanded="true"] {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}

.token-count-icon {
  display: grid;
  width: 15px;
  height: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  place-items: center;
  font-size: 8px;
  font-weight: 700;
}

.token-count-detail {
  display: none;
}

.token-count[aria-expanded="true"] .token-count-detail {
  display: inline;
}

.send-button,
.stop-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  place-items: center;
  color: #2f2118;
  background: var(--accent);
  transition: 150ms ease;
}

.send-button:hover,
.stop-button:hover {
  background: var(--accent-bright);
  transform: translateY(-1px);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.send-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

.stop-button span {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

.privacy-note {
  display: none;
  padding-top: 0;
  color: var(--muted-soft);
  font-size: 10px;
  text-align: center;
}

.sidebar-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.image-lightbox-panel {
  position: relative;
  display: flex;
  max-width: min(92vw, 980px);
  max-height: min(88vh, 820px);
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(19, 23, 35, 0.96);
}

.image-lightbox-panel .icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.36);
}

.image-lightbox-panel img {
  display: block;
  max-width: 100%;
  max-height: calc(88vh - 100px);
  border-radius: 12px;
  object-fit: contain;
}

.image-lightbox-panel p {
  max-width: 780px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-backdrop {
  z-index: 15;
  display: none;
  background: rgba(0, 0, 0, 0.46);
}

.modal-backdrop {
  z-index: 50;
  display: grid;
  padding: 22px;
  place-items: center;
  background: rgba(5, 7, 12, 0.66);
  backdrop-filter: blur(9px);
}

.settings-modal {
  width: min(100%, 680px);
  max-height: min(800px, calc(100vh - 44px));
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #181e2d;
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease-out;
}

.character-picker-modal {
  width: min(100%, 480px);
  max-height: min(680px, calc(100vh - 44px));
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #181e2d;
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease-out;
}

.character-picker-modal h2 {
  margin: 3px 0 0;
  font-size: 19px;
}

.character-picker-hint {
  margin: 0;
  padding: 0 23px 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.conversation-character-list {
  display: grid;
  gap: 9px;
  padding: 0 23px 23px;
}

.conversation-character-option {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  text-align: left;
  transition: 140ms ease;
}

.conversation-character-option:hover,
.conversation-character-option.selected {
  border-color: rgba(230, 170, 104, 0.4);
  background: var(--accent-faint);
}

.conversation-character-avatar {
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  font-size: 14px;
}

.conversation-character-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.conversation-character-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-character-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-character-check {
  margin-left: auto;
  color: var(--accent);
  font-size: 10px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.settings-header {
  padding: 21px 23px 16px;
}

.settings-header h2 {
  margin: 3px 0 0;
  font-size: 19px;
}

.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.settings-tab {
  position: relative;
  padding: 10px 5px 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}

.settings-tab + .settings-tab {
  margin-left: 18px;
}

.settings-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  border-radius: 999px;
  content: "";
  background: var(--accent);
  opacity: 0;
}

.settings-tab.active {
  color: var(--accent-bright);
}

.settings-tab.active::after {
  opacity: 1;
}

.settings-content {
  display: none;
  padding: 20px 23px 7px;
}

.settings-content.active {
  display: block;
}

.settings-intro {
  margin-bottom: 18px;
  padding: 12px 13px;
  border: 1px solid rgba(230, 170, 104, 0.12);
  border-radius: 10px;
  background: var(--accent-faint);
}

.settings-intro strong,
.switch-field strong {
  color: #f0e6dc;
  font-size: 13px;
}

.settings-intro p,
.switch-field p {
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.field {
  display: block;
  flex: 1;
  margin-bottom: 15px;
}

.field-row {
  align-items: flex-start;
  gap: 14px;
}

.field span {
  display: block;
  padding: 0 0 7px 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field em {
  color: var(--muted-soft);
  font-size: 10px;
  font-style: normal;
  font-weight: 400;
}

.field b {
  padding-left: 5px;
  color: var(--accent);
  font-size: 10px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
  transition: 150ms ease;
}

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

.field select {
  appearance: auto;
}

.field textarea {
  padding: 10px 12px;
  line-height: 1.65;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(230, 170, 104, 0.43);
  background: rgba(255, 255, 255, 0.052);
  box-shadow: 0 0 0 3px rgba(230, 170, 104, 0.05);
}

.context-summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.3fr) minmax(150px, 0.7fr);
}

.context-control-panel {
  margin: 0 0 12px;
}

.context-control-explain {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.024);
}

.context-control-explain strong {
  color: #f0e6dc;
  font-size: 13px;
}

.context-control-explain p {
  padding-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.context-control-explain > span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-faint);
  font-size: 11px;
  font-weight: 700;
}

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

.mini-button {
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: 150ms ease;
}

.mini-button:hover {
  border-color: rgba(230, 170, 104, 0.4);
  color: var(--accent);
  background: var(--accent-faint);
}

.context-summary-actions {
  margin: -2px 0 12px;
}

@media (max-width: 720px) {
  .context-summary-grid {
    grid-template-columns: 1fr;
  }

  .context-limit-input-row {
    grid-template-columns: 1fr;
  }
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 56px;
}

.password-field button {
  position: absolute;
  top: 1px;
  right: 1px;
  height: 37px;
  padding: 0 10px;
  border: 0;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.switch-field {
  gap: 13px;
  justify-content: space-between;
  margin-bottom: 11px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.switch-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 38px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  cursor: pointer;
  transition: 160ms ease;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  content: "";
  background: #bec4ce;
  transition: 160ms ease;
}

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

.switch-field input:checked + .switch::after {
  background: #35251c;
  transform: translateX(17px);
}

.settings-footer {
  gap: 16px;
  padding: 15px 23px 19px;
  border-top: 1px solid var(--line);
}

#settingsSavedHint {
  color: var(--muted-soft);
  font-size: 11px;
}

.primary-button {
  padding: 9px 18px;
  border-radius: 9px;
  color: #35251c;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
  transition: 150ms ease;
}

.primary-button:hover {
  background: var(--accent-bright);
}

.toast-container {
  position: fixed;
  z-index: 70;
  top: 17px;
  right: 17px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 34px));
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: #f7f8fb;
  background: rgba(30, 36, 52, 0.96);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
  font-size: 12px;
  line-height: 1.6;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-color: rgba(220, 126, 126, 0.33);
  color: #ffd4d4;
  background: rgba(75, 38, 45, 0.97);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(7px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.hidden,
.mobile-only {
  display: none;
}

@media (max-width: 760px) {
  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 310px);
    min-width: 0;
    transform: translateX(-102%);
    transition: transform 190ms ease;
  }

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

  .sidebar.open + .sidebar-backdrop {
    display: block;
  }

  .chat-header {
    height: 66px;
    min-height: 66px;
    padding: 0 13px;
  }

  .chat-header-left {
    min-width: 0;
    gap: 6px;
  }

  .character-header {
    min-width: 0;
    gap: 9px;
  }

  .avatar-character {
    width: 38px;
    height: 38px;
  }

  .character-title {
    min-width: 0;
  }

  .character-title p {
    max-width: min(45vw, 230px);
  }

  .header-actions {
    gap: 3px;
  }

  .settings-button {
    width: 38px;
    height: 38px;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .settings-button span {
    display: none;
  }

  .messages {
    gap: 18px;
    padding: 24px 14px 20px;
  }

  .message {
    gap: 8px;
  }

  .message .avatar {
    width: 29px;
    height: 29px;
    font-size: 11px;
  }

  .message-content {
    max-width: calc(100% - 45px);
  }

  .message-bubble {
    padding: 10px 12px;
    font-size: 15px;
  }

  .empty-state {
    padding: 30px 4px 54px;
  }

  .empty-state h2 {
    font-size: 26px;
  }

  .empty-state p {
    max-width: 290px;
    font-size: 12px;
  }

  .starter-list {
    gap: 7px;
    margin-top: 18px;
  }

  .starter {
    padding: 8px 10px;
    font-size: 11px;
  }

  .composer-wrap {
    padding: 0 10px 8px;
  }

  .pending-attachments {
    gap: 6px;
  }

  .pending-attachment {
    max-width: 46vw;
  }

  .branch-recovery {
    gap: 8px;
    padding: 8px 9px;
  }

  .branch-recovery span {
    max-width: 54vw;
  }

  .composer {
    padding: 7px 7px 7px 12px;
    border-radius: 14px;
  }

  .attach-button {
    width: 31px;
    height: 31px;
    border-radius: 9px;
  }

  .message-image-card,
  .image-summary {
    max-width: 72vw;
  }

  .composer-hint {
    display: none;
  }

  .privacy-note {
    display: none;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .onboarding-screen {
    align-items: end;
    padding: 0;
  }

  .onboarding-card {
    width: 100%;
    max-height: 92vh;
    padding: 22px 16px 18px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .onboarding-options {
    display: block;
  }

  .settings-modal {
    width: 100%;
    max-height: min(88vh, 800px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .character-picker-modal {
    width: 100%;
    max-height: min(82vh, 680px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }

  .image-lightbox {
    padding: 12px;
  }

  .settings-header {
    padding: 18px 17px 13px;
  }

  .settings-tabs {
    padding: 0 16px;
  }

  .settings-content {
    padding: 17px 16px 5px;
  }

  .field-row {
    display: block;
  }

  .settings-footer {
    padding: 13px 16px 16px;
  }
}

/* Enhanced controls */

code {
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--accent-bright);
  background: var(--accent-faint);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.field select {
  width: 100%;
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  font-size: 13px;
  transition: 150ms ease;
}

.field select:focus {
  border-color: rgba(230, 170, 104, 0.43);
  box-shadow: 0 0 0 3px rgba(230, 170, 104, 0.05);
}

.field select option {
  color: var(--text);
  background: var(--panel-solid);
}

.field small {
  display: block;
  padding: 6px 2px 0;
  color: var(--muted-soft);
  font-size: 11px;
  line-height: 1.55;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.secondary-button,
.danger-button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font-size: 12px;
  transition: 150ms ease;
}

.secondary-button:hover {
  border-color: rgba(230, 170, 104, 0.34);
  color: var(--accent-bright);
  background: var(--accent-faint);
}

.danger-button:hover {
  border-color: rgba(220, 126, 126, 0.34);
  color: var(--danger);
  background: rgba(220, 126, 126, 0.08);
}

.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.action-hint {
  color: var(--muted-soft);
  font-size: 11px;
}

.settings-section-divider {
  height: 1px;
  margin: 18px 0 14px;
  background: var(--line);
}

.character-generator-card {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.character-generator-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.character-generator-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.character-generator-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.character-generator-card .field {
  margin-bottom: 12px;
}

.character-generator-actions {
  margin: 8px 0 0;
}

.character-draft-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.character-manager {
  display: flex;
  align-items: end;
  gap: 13px;
}

.character-manager .field {
  min-width: 0;
}

.character-actions {
  flex: 0 0 auto;
  margin: 0 0 15px;
}

.data-card {
  margin: 0 0 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.compact-switch {
  margin-top: 12px;
  margin-bottom: 3px;
}

.data-card strong {
  color: #f0e6dc;
  font-size: 12px;
}

.data-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 13px;
}

.admin-invite-code {
  margin: 11px 0 3px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 7px;
}

.admin-stat-grid span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 11px;
}

.admin-stat-grid b {
  float: right;
  color: var(--text);
  font-size: 12px;
}

.admin-card-heading,
.admin-user-row,
.admin-user-title,
.admin-user-meta,
.admin-user-actions {
  display: flex;
}

.admin-card-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-card-heading > span {
  flex: 0 0 auto;
  color: var(--muted-soft);
  font-size: 11px;
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-trace-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-user-row {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
}

.admin-trace-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
}

.admin-trace-row.success {
  border-color: rgba(63, 180, 106, 0.22);
}

.admin-trace-row.error {
  border-color: rgba(220, 126, 126, 0.24);
}

.admin-trace-main {
  min-width: 0;
}

.admin-trace-preview {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin-trace-detail textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
}

.admin-user-row.disabled {
  opacity: 0.72;
}

.admin-user-main {
  min-width: 0;
}

.admin-user-title {
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-user-title strong {
  color: var(--text);
  font-size: 13px;
}

.admin-role-badge,
.admin-status-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.admin-status-badge.active {
  color: #3fb46a;
  background: rgba(63, 180, 106, 0.12);
}

.admin-status-badge.disabled {
  color: var(--danger);
  background: rgba(220, 126, 126, 0.1);
}

.admin-status-badge.self {
  color: var(--accent);
  background: var(--accent-faint);
}

.mini-checkbox {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  gap: 7px;
  padding: 8px 11px;
}

.mini-checkbox input {
  accent-color: var(--accent);
}

.admin-user-meta {
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 7px;
  color: var(--muted-soft);
  font-size: 11px;
}

.admin-user-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-user-actions .secondary-button,
.admin-user-actions .danger-button {
  padding: 6px 9px;
  font-size: 11px;
}

.admin-detail-card {
  margin-top: 13px;
}

.admin-detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 13px;
}

.admin-detail-panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.admin-detail-panel > strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
}

.admin-message-list {
  max-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 12px;
  padding-right: 3px;
}

.admin-message {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.admin-message.user {
  border-color: rgba(72, 187, 120, 0.28);
  background: rgba(72, 187, 120, 0.08);
}

.admin-message-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--muted-soft);
  font-size: 10px;
}

.admin-message-head strong {
  color: var(--text);
  font-size: 12px;
}

.admin-message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
  line-height: 1.7;
}

.admin-message-attachment,
.admin-message-reasoning {
  margin-top: 7px;
  padding: 7px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.admin-message-reasoning pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 7px 0 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.admin-config-editor textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
}

@media (max-width: 760px) {
  .admin-overview-grid,
  .admin-stat-grid,
  .admin-detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-card-heading,
  .admin-user-row,
  .admin-trace-row {
    flex-direction: column;
  }

  .admin-user-actions {
    justify-content: flex-start;
  }
}

.archive-manager {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.archive-manager .field {
  margin-bottom: 10px;
}

.archive-actions {
  margin: 4px 0 2px;
}

.archive-note {
  margin-top: 9px;
  padding-top: 0;
  color: var(--muted-soft);
  font-size: 10px;
}

.memory-dashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.memory-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

.memory-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.memory-status-dot.online { background: #22c55e; }
.memory-status-dot.offline { background: #ef4444; }
.memory-status-dot.checking {
  background: #f59e0b;
  animation: pulse 1s ease-in-out infinite;
}

.memory-scope-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.memory-scope-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
  flex: 1;
}

.memory-clear-character-btn {
  flex-shrink: 0;
}

.memory-scope-select span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.memory-scope-select select {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}

.memory-scope-select select:focus {
  border-color: var(--accent);
  outline: none;
}

.memory-scope-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.memory-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.memory-overview-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.memory-overview-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.memory-overview-card strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
  font-size: 20px;
  line-height: 1.15;
}

.memory-overview-card small {
  color: var(--muted-soft);
  font-size: 10px;
  line-height: 1.35;
}

.memory-overview-card.warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.07);
}

.memory-overview-card.healthy {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.07);
}

.memory-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  min-height: 0;
}

.memory-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-search-input {
  width: 100%;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  box-sizing: border-box;
}
.memory-search-input::placeholder { color: var(--muted); }
.memory-search-input:focus { border-color: var(--accent); outline: none; }

.memory-filter-row {
  display: flex;
  gap: 6px;
}

.memory-filter-select {
  flex: 1;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
}
.memory-filter-select:focus { border-color: var(--accent); outline: none; }

.memory-stats-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.memory-stats-card > strong {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.memory-stats-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memory-dist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.memory-dist-label { color: var(--muted); width: 56px; flex-shrink: 0; }
.memory-dist-count { color: var(--text); width: 24px; text-align: right; font-weight: 600; }
.memory-dist-bar { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.06); border-radius: 2px; overflow: hidden; }
.memory-dist-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 300ms ease; }

.memory-loop-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.memory-loop-item:last-child { border-bottom: none; }
.memory-loop-item p {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 12px;
}
.memory-loop-item .inline-actions { margin-top: 4px; }
.memory-loop-item .secondary-button { font-size: 10px; padding: 2px 6px; }

.memory-relationship-panel {
  font-size: 12px;
}
.memory-rel-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.memory-rel-row span:first-child { color: var(--muted); }

.memory-add-fact-btn {
  width: 100%;
  font-size: 11px !important;
}

.memory-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 500px;
}

.memory-recall-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.memory-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.memory-card-title-row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.memory-card-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.memory-recall-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.memory-recall-item {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.memory-recall-rank {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 11px;
  font-weight: 700;
}

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

.memory-recall-body p {
  margin: 5px 0 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.memory-recall-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.memory-recall-score {
  color: var(--muted);
  font-size: 10px;
}

.memory-recall-note {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.memory-recall-note strong {
  margin-right: 6px;
  color: var(--accent);
}

.memory-fact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.memory-fact-header strong { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.memory-fact-count { font-size: 11px; color: var(--muted); }

.memory-fact-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 420px;
}

.memory-fact-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.015);
  gap: 8px;
}
.memory-fact-row:hover { background: rgba(255, 255, 255, 0.03); }

.memory-fact-row-main { flex: 1; min-width: 0; }
.memory-fact-row-content {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}
.memory-fact-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}
.memory-fact-row-time {
  font-size: 10px;
  color: var(--muted-soft);
  display: block;
}
.memory-fact-row-scores {
  display: flex;
  gap: 12px;
  font-size: 10px;
  color: var(--muted);
}

.memory-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.memory-tag-modality { color: var(--accent); }
.memory-tag-locked { color: #f59e0b; }
.memory-tag-scope { color: #8b5cf6; }

.memory-fact-row-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: flex-start;
}
.memory-action-btn {
  font-size: 10px !important;
  padding: 2px 6px !important;
}

.memory-pagination {
  display: flex;
  justify-content: center;
  padding: 4px 0;
}
.memory-page-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}
.memory-page-nav button { font-size: 11px; padding: 3px 8px; }

.memory-bottom-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.memory-panel-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.memory-panel-card > strong {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.memory-panel-card .secondary-button {
  margin-top: 6px;
  font-size: 11px;
}

.memory-reflections-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.memory-reflection-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.memory-reflection-item:last-child { border-bottom: none; }
.memory-reflection-item p { margin: 0 0 4px; color: var(--text); }

.memory-jobs-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.memory-job-item {
  font-size: 10px;
  color: var(--muted);
  padding: 2px 0;
}
.memory-job-item.job-succeeded { color: #22c55e; }
.memory-job-item.job-failed { color: #ef4444; }
.memory-job-item.job-pending { color: #f59e0b; }

.memory-config-bar {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.memory-config-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}
.memory-config-row + .memory-config-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.memory-config-row .compact-switch {
  margin: 0;
}
.memory-config-row .compact-switch div strong {
  font-size: 11px;
}

.memory-config-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.memory-config-input {
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  width: 180px;
}
.memory-config-input:focus { border-color: var(--accent); outline: none; }
.memory-config-narrow { width: 70px; }

.memory-config-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.memory-config-actions .field {
  margin-bottom: 0;
}

.memory-fact-edit-modal,
.memory-fact-add-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.memory-fact-edit-modal.hidden,
.memory-fact-add-modal.hidden {
  display: none;
}
.memory-fact-edit-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.memory-fact-edit-dialog {
  position: relative;
  width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.memory-fact-edit-dialog .settings-header {
  margin-bottom: 0;
}
.memory-fact-edit-dialog .settings-header strong {
  font-size: 14px;
}
.memory-fact-edit-dialog .field {
  margin-bottom: 0;
}

@media (max-width: 820px) {
  .memory-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-scope-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .memory-scope-select {
    min-width: 0;
  }

  .memory-layout {
    grid-template-columns: 1fr;
  }
  .memory-card-title-row {
    flex-direction: column;
  }
  .memory-card-title-row .secondary-button {
    align-self: flex-start;
  }
  .memory-fact-table {
    max-height: 300px;
  }
  .memory-panel-row {
    grid-template-columns: 1fr;
  }
  .memory-fact-row {
    flex-direction: column;
  }
  .memory-fact-row-actions {
    width: 100%;
  }
  .memory-config-input {
    width: 120px;
  }
  .memory-fact-edit-dialog {
    width: 95vw;
  }
}

.memory-fact-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.memory-fact-item p {
  margin: 0 0 7px;
  color: var(--text);
}

.memory-fact-meta {
  color: var(--muted-soft);
  font-size: 10px;
}

.message-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.message:hover .message-tools,
.message:focus-within .message-tools {
  opacity: 1;
}

.message.user .message-tools {
  justify-content: flex-end;
}

.message-version-switcher {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 5px;
  margin-top: -1px;
  padding: 2px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted-soft);
  background: transparent;
  font-size: 10px;
  line-height: 1;
  opacity: 0.72;
  transition: 150ms ease;
}

.message.user .message-version-switcher {
  align-self: flex-end;
}

.message-version-switcher:hover,
.message:focus-within .message-version-switcher {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
  opacity: 1;
}

.message-version-switcher button {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: 130ms ease;
}

.message-version-switcher button:hover {
  color: var(--accent-bright);
  background: var(--accent-faint);
}

.message-version-switcher button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.message-version-switcher span {
  min-width: 30px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.message-tools button {
  padding: 3px 5px;
  border: 0;
  border-radius: 4px;
  color: var(--muted-soft);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  transition: 130ms ease;
}

.message-tools button:hover {
  color: var(--accent-bright);
  background: var(--accent-faint);
}

.conversation-item-icon {
  display: grid;
  width: 19px;
  height: 19px;
  border-color: rgba(230, 170, 104, 0.46);
  place-items: center;
  color: var(--accent-bright);
  font-size: 9px;
}

.conversation-item.active .conversation-item-icon {
  color: #34241a;
}

.settings-modal {
  width: min(100%, 760px);
}

.settings-tabs {
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

/* WeChat-inspired light theme */

:root[data-theme="wechat"] {
  color-scheme: light;
  --bg: var(--wechat-page);
  --bg-deep: #d9d9d9;
  --panel: rgba(247, 247, 247, 0.98);
  --panel-soft: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --line: rgba(0, 0, 0, 0.075);
  --line-strong: rgba(0, 0, 0, 0.12);
  --text: #171717;
  --muted: #666666;
  --muted-soft: #929292;
  --accent: #07c160;
  --accent-bright: #06ad56;
  --accent-soft: rgba(7, 193, 96, 0.13);
  --accent-faint: rgba(7, 193, 96, 0.07);
  --danger: #d14b4b;
  --success: #07c160;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.1);
}

:root[data-theme="wechat"] .ambient {
  display: none;
}

:root[data-theme="wechat"] body,
:root[data-theme="wechat"] .chat-panel {
  background: var(--wechat-page);
}

:root[data-theme="wechat"] .sidebar,
:root[data-theme="wechat"] .chat-header {
  background: rgba(247, 247, 247, 0.98);
  backdrop-filter: none;
}

:root[data-theme="wechat"] .sidebar {
  border-right-color: rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

:root[data-theme="wechat"] .chat-header {
  height: 64px;
  min-height: 64px;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="wechat"] .brand-mark {
  border: 0;
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat"] .new-chat-button {
  border-color: transparent;
  border-radius: 8px;
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat"] .new-chat-button:hover {
  border-color: transparent;
  background: #06ad56;
}

:root[data-theme="wechat"] .conversation-item {
  margin: 0;
  border-radius: 6px;
  color: #4c4c4c;
}

:root[data-theme="wechat"] .conversation-item:hover,
:root[data-theme="wechat"] .conversation-item.active {
  border-color: transparent;
  color: #111111;
  background: #e6e6e6;
}

:root[data-theme="wechat"] .conversation-item.active .conversation-item-icon {
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat"] .icon-button,
:root[data-theme="wechat"] .settings-button,
:root[data-theme="wechat"] .conversation-character-button {
  border-color: transparent;
  color: #4c4c4c;
  background: transparent;
}

:root[data-theme="wechat"] .icon-button:hover,
:root[data-theme="wechat"] .settings-button:hover,
:root[data-theme="wechat"] .conversation-character-button:hover {
  color: #111111;
  background: rgba(0, 0, 0, 0.055);
}

:root[data-theme="wechat"] .composer-wrap {
  padding: 9px 16px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #f7f7f7;
}

:root[data-theme="wechat"] .composer {
  width: min(100%, 900px);
  padding: 7px 8px 7px 14px;
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: none;
}

:root[data-theme="wechat"] .pending-attachment,
:root[data-theme="wechat"] .message-image-card,
:root[data-theme="wechat"] .attach-button,
:root[data-theme="wechat"] .image-policy-actions {
  border-color: rgba(0, 0, 0, 0.08);
  background: #ffffff;
}

:root[data-theme="wechat"] .attach-button:hover {
  color: #07c160;
  border-color: rgba(7, 193, 96, 0.22);
  background: rgba(7, 193, 96, 0.08);
}

:root[data-theme="wechat"] .image-policy-actions button.active {
  color: #ffffff;
  background: #07c160;
}

:root[data-theme="wechat"] .composer:focus-within {
  border-color: rgba(7, 193, 96, 0.24);
  box-shadow: none;
}

:root[data-theme="wechat"] #messageInput {
  color: #111111;
  font-size: 16px;
  line-height: 1.45;
}

:root[data-theme="wechat"] .send-button,
:root[data-theme="wechat"] .stop-button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat"] .send-button:hover,
:root[data-theme="wechat"] .stop-button:hover {
  background: #06ad56;
  transform: none;
}

:root[data-theme="wechat"] .messages {
  width: min(100%, 960px);
  gap: 22px;
  padding-top: 26px;
}

:root[data-theme="wechat"] .message-bubble {
  border-color: rgba(0, 0, 0, 0.04);
  border-radius: 4px 16px 16px;
  color: #191919;
  background: #ffffff;
  box-shadow: none;
  font-size: 16px;
  line-height: 1.68;
}

:root[data-theme="wechat"] .message.user .message-bubble {
  border-color: rgba(90, 160, 54, 0.18);
  color: #10220d;
  background: var(--wechat-bubble-user);
  border-radius: 16px 4px 16px 16px;
}

:root[data-theme="wechat"] .message.error .message-bubble {
  color: #8b3030;
  background: #ffecec;
}

:root[data-theme="wechat"] .image-summary {
  color: #8a8a8a;
}

:root[data-theme="wechat"] .message .avatar {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

:root[data-theme="wechat"] .message.user .avatar {
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat"] .message-meta {
  color: #8a8a8a;
  font-size: 11px;
}

:root[data-theme="wechat"] .message-tools button,
:root[data-theme="wechat"] .message-version-switcher {
  color: #8a8a8a;
}

:root[data-theme="wechat"] .message-tools button:hover,
:root[data-theme="wechat"] .message-version-switcher button:hover {
  color: #07c160;
  background: rgba(7, 193, 96, 0.08);
}

:root[data-theme="wechat"] .message-version-switcher:hover,
:root[data-theme="wechat"] .message:focus-within .message-version-switcher {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.7);
}

:root[data-theme="wechat"] .settings-modal,
:root[data-theme="wechat"] .character-picker-modal,
:root[data-theme="wechat"] .onboarding-card {
  border: 0;
  border-radius: 12px;
  background: #f7f7f7;
  box-shadow: var(--shadow);
}

:root[data-theme="wechat"] .onboarding-screen {
  background: rgba(237, 237, 237, 0.82);
}

:root[data-theme="wechat"] .onboarding-card h1 {
  color: #111111;
}

:root[data-theme="wechat"] .onboarding-copy {
  color: #666666;
}

:root[data-theme="wechat"] .settings-header,
:root[data-theme="wechat"] .settings-footer {
  background: #f7f7f7;
}

:root[data-theme="wechat"] .settings-tabs {
  gap: 0;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="wechat"] .settings-tab {
  color: #666666;
  font-size: 14px;
}

:root[data-theme="wechat"] .settings-tab.active {
  color: #07c160;
}

:root[data-theme="wechat"] .settings-content {
  padding-top: 16px;
}

:root[data-theme="wechat"] .settings-intro {
  border: 0;
  border-radius: 10px;
  color: #4c4c4c;
  background: #ffffff;
}

:root[data-theme="wechat"] .settings-intro strong,
:root[data-theme="wechat"] .switch-field strong,
:root[data-theme="wechat"] .data-card strong {
  color: #111111;
}

:root[data-theme="wechat"] .field,
:root[data-theme="wechat"] .character-generator-card,
:root[data-theme="wechat"] .switch-field,
:root[data-theme="wechat"] .data-card,
:root[data-theme="wechat"] .memory-scope-bar,
:root[data-theme="wechat"] .memory-overview-card,
:root[data-theme="wechat"] .memory-stats-card,
:root[data-theme="wechat"] .memory-recall-card,
:root[data-theme="wechat"] .memory-panel-card,
:root[data-theme="wechat"] .memory-config-bar,
:root[data-theme="wechat"] .memory-config-actions {
  border-color: transparent;
  background: #ffffff;
  box-shadow: none;
}

:root[data-theme="wechat"] .field {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
}

:root[data-theme="wechat"] .onboarding-card .field {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

:root[data-theme="wechat"] .onboarding-draft {
  border-top-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="wechat"] .field-row {
  gap: 10px;
}

:root[data-theme="wechat"] .field span {
  color: #333333;
  font-size: 13px;
}

:root[data-theme="wechat"] .context-control-explain {
  border-color: transparent;
  border-radius: 10px;
  background: #ffffff;
}

:root[data-theme="wechat"] .context-control-explain strong {
  color: #111111;
}

:root[data-theme="wechat"] .context-control-explain p {
  color: #666666;
}

:root[data-theme="wechat"] .context-control-explain > span {
  color: #07c160;
  background: rgba(7, 193, 96, 0.08);
}

:root[data-theme="wechat"] .mini-button {
  border-color: rgba(0, 0, 0, 0.08);
  color: #07c160;
  background: #f7f7f7;
}

:root[data-theme="wechat"] .mini-button:hover {
  border-color: rgba(7, 193, 96, 0.28);
  color: #07c160;
  background: rgba(7, 193, 96, 0.08);
}

:root[data-theme="wechat"] .character-generator-head strong {
  color: #111111;
}

:root[data-theme="wechat"] .character-generator-head p {
  color: #666666;
}

:root[data-theme="wechat"] .character-draft-preview {
  border-top-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="wechat"] .field input,
:root[data-theme="wechat"] .field textarea,
:root[data-theme="wechat"] .field select {
  border-color: rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  color: #111111;
  background: #f7f7f7;
  font-size: 14px;
}

:root[data-theme="wechat"] .field input:focus,
:root[data-theme="wechat"] .field textarea:focus,
:root[data-theme="wechat"] .field select:focus {
  border-color: rgba(7, 193, 96, 0.38);
  background: #ffffff;
  box-shadow: none;
}

:root[data-theme="wechat"] .switch-field {
  border-radius: 10px;
}

:root[data-theme="wechat"] .switch {
  background: #d8d8d8;
}

:root[data-theme="wechat"] .switch::after {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
}

:root[data-theme="wechat"] .switch-field input:checked + .switch {
  background: #07c160;
}

:root[data-theme="wechat"] .switch-field input:checked + .switch::after {
  background: #ffffff;
}

:root[data-theme="wechat"] .primary-button,
:root[data-theme="wechat"] .secondary-button:hover {
  border-color: transparent;
  color: #ffffff;
  background: #07c160;
}

:root[data-theme="wechat"] .secondary-button,
:root[data-theme="wechat"] .danger-button {
  border-color: transparent;
  color: #4c4c4c;
  background: #f0f0f0;
}

:root[data-theme="wechat"] .danger-button:hover {
  color: #d14b4b;
  background: #fff0f0;
}

:root[data-theme="wechat"] .toast {
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.78);
  box-shadow: none;
}

/* WeChat-inspired night theme */

:root[data-theme="wechat-night"] {
  color-scheme: dark;
  --bg: #111315;
  --bg-deep: #0d0f12;
  --panel: rgba(28, 30, 34, 0.98);
  --panel-soft: rgba(36, 39, 44, 0.92);
  --panel-solid: #1f2227;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f0f0;
  --muted: #a2a2a2;
  --muted-soft: #777777;
  --accent: #07c160;
  --accent-bright: #19d66f;
  --accent-soft: rgba(7, 193, 96, 0.16);
  --accent-faint: rgba(7, 193, 96, 0.08);
  --danger: #ff6b6b;
  --success: #07c160;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  --wechat-bubble-user: #1f8f4d;
  --wechat-page: #111315;
  --wechat-bar: #191b1f;
}

:root[data-theme="wechat-night"] .ambient {
  display: none;
}

:root[data-theme="wechat-night"] .cloud-auth-screen {
  background: rgba(13, 15, 18, 0.88);
}

:root[data-theme="wechat-night"] .onboarding-screen {
  background: rgba(13, 15, 18, 0.88);
}

:root[data-theme="wechat-night"] .cloud-auth-card {
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text);
  background: rgba(31, 34, 39, 0.98);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

:root[data-theme="wechat-night"] .onboarding-card {
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text);
  background: #191b1f;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

:root[data-theme="wechat-night"] .cloud-auth-copy {
  color: var(--muted);
}

:root[data-theme="wechat-night"] .onboarding-copy {
  color: var(--muted);
}

:root[data-theme="wechat-night"] .onboarding-card .field {
  padding: 0;
  border-radius: 0;
  background: transparent;
}

:root[data-theme="wechat-night"] .onboarding-draft {
  border-top-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] body,
:root[data-theme="wechat-night"] .chat-panel {
  background: var(--wechat-page);
}

:root[data-theme="wechat-night"] .sidebar,
:root[data-theme="wechat-night"] .chat-header {
  background: rgba(25, 27, 31, 0.98);
  backdrop-filter: none;
}

:root[data-theme="wechat-night"] .sidebar {
  border-right-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

:root[data-theme="wechat-night"] .chat-header {
  height: 64px;
  min-height: 64px;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] .brand-mark,
:root[data-theme="wechat-night"] .new-chat-button,
:root[data-theme="wechat-night"] .send-button,
:root[data-theme="wechat-night"] .stop-button,
:root[data-theme="wechat-night"] .primary-button,
:root[data-theme="wechat-night"] .secondary-button:hover {
  border-color: transparent;
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .new-chat-button {
  border-radius: 8px;
}

:root[data-theme="wechat-night"] .new-chat-button:hover,
:root[data-theme="wechat-night"] .send-button:hover,
:root[data-theme="wechat-night"] .stop-button:hover {
  background: #06ad56;
  transform: none;
}

:root[data-theme="wechat-night"] .conversation-item {
  margin: 0;
  border-radius: 6px;
  color: #c8c8c8;
}

:root[data-theme="wechat-night"] .conversation-item:hover,
:root[data-theme="wechat-night"] .conversation-item.active {
  border-color: transparent;
  color: #ffffff;
  background: #25282d;
}

:root[data-theme="wechat-night"] .conversation-item.active .conversation-item-icon {
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .icon-button,
:root[data-theme="wechat-night"] .settings-button,
:root[data-theme="wechat-night"] .conversation-character-button {
  border-color: transparent;
  color: #c8c8c8;
  background: transparent;
}

:root[data-theme="wechat-night"] .icon-button:hover,
:root[data-theme="wechat-night"] .settings-button:hover,
:root[data-theme="wechat-night"] .conversation-character-button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] .composer-wrap {
  padding: 9px 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #191b1f;
}

:root[data-theme="wechat-night"] .composer {
  width: min(100%, 900px);
  padding: 7px 8px 7px 14px;
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: #202328;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .composer:focus-within {
  border-color: rgba(7, 193, 96, 0.28);
  box-shadow: none;
}

:root[data-theme="wechat-night"] #messageInput {
  color: #f0f0f0;
  font-size: 16px;
  line-height: 1.45;
}

:root[data-theme="wechat-night"] .send-button,
:root[data-theme="wechat-night"] .stop-button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

:root[data-theme="wechat-night"] .pending-attachment,
:root[data-theme="wechat-night"] .message-image-card,
:root[data-theme="wechat-night"] .attach-button,
:root[data-theme="wechat-night"] .image-policy-actions {
  border-color: rgba(255, 255, 255, 0.08);
  background: #202328;
}

:root[data-theme="wechat-night"] .attach-button:hover {
  color: #19d66f;
  border-color: rgba(7, 193, 96, 0.28);
  background: rgba(7, 193, 96, 0.1);
}

:root[data-theme="wechat-night"] .image-policy-actions button.active {
  color: #ffffff;
  background: #07c160;
}

:root[data-theme="wechat-night"] .messages {
  width: min(100%, 960px);
  gap: 22px;
  padding-top: 26px;
}

:root[data-theme="wechat-night"] .message-bubble {
  border-color: rgba(255, 255, 255, 0.06);
  border-radius: 4px 16px 16px;
  color: #f1f1f1;
  background: #25282d;
  box-shadow: none;
  font-size: 16px;
  line-height: 1.68;
}

:root[data-theme="wechat-night"] .message.user .message-bubble {
  border-color: rgba(7, 193, 96, 0.22);
  color: #f5fff7;
  background: var(--wechat-bubble-user);
  border-radius: 16px 4px 16px 16px;
}

:root[data-theme="wechat-night"] .message.error .message-bubble {
  color: #ffd3d3;
  background: rgba(255, 88, 88, 0.14);
}

:root[data-theme="wechat-night"] .image-summary,
:root[data-theme="wechat-night"] .message-meta,
:root[data-theme="wechat-night"] .message-tools button,
:root[data-theme="wechat-night"] .message-version-switcher {
  color: #8f8f8f;
}

:root[data-theme="wechat-night"] .message .avatar {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] .message.user .avatar {
  color: #ffffff;
  background: #07c160;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .message-meta {
  font-size: 11px;
}

:root[data-theme="wechat-night"] .message-tools button:hover,
:root[data-theme="wechat-night"] .message-version-switcher button:hover {
  color: #19d66f;
  background: rgba(7, 193, 96, 0.1);
}

:root[data-theme="wechat-night"] .message-version-switcher:hover,
:root[data-theme="wechat-night"] .message:focus-within .message-version-switcher {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(32, 35, 40, 0.82);
}

:root[data-theme="wechat-night"] .settings-modal,
:root[data-theme="wechat-night"] .character-picker-modal {
  border: 0;
  border-radius: 12px;
  background: #191b1f;
  box-shadow: var(--shadow);
}

:root[data-theme="wechat-night"] .settings-header,
:root[data-theme="wechat-night"] .settings-footer {
  background: #191b1f;
}

:root[data-theme="wechat-night"] .settings-tabs {
  gap: 0;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] .settings-tab {
  color: #a2a2a2;
  font-size: 14px;
}

:root[data-theme="wechat-night"] .settings-tab.active {
  color: #19d66f;
}

:root[data-theme="wechat-night"] .settings-content {
  padding-top: 16px;
}

:root[data-theme="wechat-night"] .settings-intro,
:root[data-theme="wechat-night"] .field,
:root[data-theme="wechat-night"] .character-generator-card,
:root[data-theme="wechat-night"] .switch-field,
:root[data-theme="wechat-night"] .data-card,
:root[data-theme="wechat-night"] .memory-scope-bar,
:root[data-theme="wechat-night"] .memory-overview-card,
:root[data-theme="wechat-night"] .memory-stats-card,
:root[data-theme="wechat-night"] .memory-recall-card,
:root[data-theme="wechat-night"] .memory-panel-card,
:root[data-theme="wechat-night"] .memory-config-bar,
:root[data-theme="wechat-night"] .memory-config-actions,
:root[data-theme="wechat-night"] .context-control-explain {
  border-color: transparent;
  background: #202328;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .settings-intro,
:root[data-theme="wechat-night"] .context-control-explain {
  border-radius: 10px;
}

:root[data-theme="wechat-night"] .settings-intro,
:root[data-theme="wechat-night"] .settings-intro p,
:root[data-theme="wechat-night"] .switch-field p,
:root[data-theme="wechat-night"] .context-control-explain p,
:root[data-theme="wechat-night"] .character-generator-head p {
  color: #a2a2a2;
}

:root[data-theme="wechat-night"] .settings-intro strong,
:root[data-theme="wechat-night"] .switch-field strong,
:root[data-theme="wechat-night"] .data-card strong,
:root[data-theme="wechat-night"] .context-control-explain strong,
:root[data-theme="wechat-night"] .character-generator-head strong {
  color: #f0f0f0;
}

:root[data-theme="wechat-night"] .field {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
}

:root[data-theme="wechat-night"] .field-row {
  gap: 10px;
}

:root[data-theme="wechat-night"] .field span {
  color: #dedede;
  font-size: 13px;
}

:root[data-theme="wechat-night"] .context-control-explain > span {
  color: #19d66f;
  background: rgba(7, 193, 96, 0.1);
}

:root[data-theme="wechat-night"] .mini-button,
:root[data-theme="wechat-night"] .secondary-button,
:root[data-theme="wechat-night"] .danger-button {
  border-color: transparent;
  color: #d4d4d4;
  background: #2a2d32;
}

:root[data-theme="wechat-night"] .mini-button {
  color: #19d66f;
}

:root[data-theme="wechat-night"] .mini-button:hover {
  border-color: rgba(7, 193, 96, 0.28);
  color: #19d66f;
  background: rgba(7, 193, 96, 0.1);
}

:root[data-theme="wechat-night"] .danger-button:hover {
  color: #ff8a8a;
  background: rgba(255, 88, 88, 0.12);
}

:root[data-theme="wechat-night"] .character-draft-preview {
  border-top-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="wechat-night"] .field input,
:root[data-theme="wechat-night"] .field textarea,
:root[data-theme="wechat-night"] .field select {
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #f0f0f0;
  background: #191b1f;
  font-size: 14px;
}

:root[data-theme="wechat-night"] .field input:focus,
:root[data-theme="wechat-night"] .field textarea:focus,
:root[data-theme="wechat-night"] .field select:focus {
  border-color: rgba(7, 193, 96, 0.34);
  background: #22252a;
  box-shadow: none;
}

:root[data-theme="wechat-night"] .field select option {
  color: #f0f0f0;
  background: #191b1f;
}

:root[data-theme="wechat-night"] .switch-field {
  border-radius: 10px;
}

:root[data-theme="wechat-night"] .switch {
  background: #4a4d52;
}

:root[data-theme="wechat-night"] .switch::after {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.26);
}

:root[data-theme="wechat-night"] .switch-field input:checked + .switch {
  background: #07c160;
}

:root[data-theme="wechat-night"] .switch-field input:checked + .switch::after {
  background: #ffffff;
}

:root[data-theme="wechat-night"] .toast {
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.82);
  box-shadow: none;
}

@media (max-width: 760px) {
  .message-tools {
    opacity: 1;
  }

  .character-manager {
    display: block;
  }

  .character-actions {
    margin-top: -7px;
  }

  .settings-tabs {
    white-space: nowrap;
  }
}
