:root {
  --brand: #4d6bfe;
  --brand-hover: #3f5cea;
  --brand-soft: #eef2ff;
  --text: #1f2329;
  --text-2: #4a505a;
  --muted: #8b919b;
  --faint: #a7acb5;
  --line: #e7e9ed;
  --line-soft: #eff1f4;
  --sidebar-bg: #fafafa;
  --bubble: #eef2f7;
  --surface: #ffffff;
  --success: #22c55e;
  --danger: #ef4444;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

a {
  color: inherit;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-14,
.icon-16,
.icon-17,
.icon-18,
.icon-19,
.icon-20,
.icon-22,
.icon-28 {
  display: block;
  flex: none;
}

.icon-14 { width: 14px; height: 14px; }
.icon-16 { width: 16px; height: 16px; }
.icon-17 { width: 17px; height: 17px; }
.icon-18 { width: 18px; height: 18px; }
.icon-19 { width: 19px; height: 19px; }
.icon-20 { width: 20px; height: 20px; }
.icon-22 { width: 22px; height: 22px; }
.icon-28 { width: 28px; height: 28px; }

/* =========================
   User app
   ========================= */

.user-body {
  overflow: hidden;
}

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex: 0 0 264px;
  flex-direction: column;
  width: 264px;
  padding: 16px 12px 12px;
  background: var(--sidebar-bg);
  border-right: 1px solid #ededf0;
}

.sidebar-scrim {
  display: none;
}

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

.brand-name {
  color: #1b1f25;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.brand-cn {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  color: #707784;
  background: #eef0f3;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.04em;
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 3px 8px rgba(77, 107, 254, 0.22);
  transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.new-chat:hover {
  background: var(--brand-hover);
  box-shadow: 0 4px 12px rgba(77, 107, 254, 0.28);
}

.new-chat:active {
  transform: translateY(1px);
}

.side-section {
  margin-top: 25px;
  min-height: 0;
}

.side-section-label {
  padding: 0 10px 8px;
  color: #9ca1a9;
  font-size: 12px;
  font-weight: 500;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px;
  color: #343940;
  background: #eef0f3;
  border: 0;
  border-radius: 9px;
  font-size: 13.5px;
  text-align: left;
  transition: background 0.15s ease;
}

.history-item:hover {
  background: #e8ebef;
}

.history-item .icon-16 {
  color: #737a85;
}

.history-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
}

.user-row:hover {
  background: #f0f1f4;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  color: #fff;
  background: linear-gradient(135deg, #7b91ff, #4d6bfe);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  user-select: none;
}

.avatar-sm {
  width: 31px;
  height: 31px;
  font-size: 12px;
}

.user-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.user-name {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.35;
}

.user-plan {
  color: #9aa0a9;
  font-size: 11.5px;
  line-height: 1.35;
}

.main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  background: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 62px;
  padding: 0 22px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-menu {
  display: none !important;
}

.model-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 35px;
  padding: 0 11px;
  color: #3e444d;
  background: #fff;
  border: 1px solid #e4e6ea;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.model-pill:hover {
  background: #f8f9fa;
  border-color: #d9dce1;
}

.model-dot {
  width: 6px;
  height: 6px;
  background: var(--brand);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(77, 107, 254, 0.12);
}

.model-pill .icon-14 {
  margin-left: 1px;
  color: #8a9099;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  padding: 0;
  color: #69717c;
  background: transparent;
  border: 0;
  border-radius: 9px;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  color: #3f4650;
  background: #f3f4f6;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.chat-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  min-height: 100%;
  margin: 0 auto;
  padding: 8px 28px 20px;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: auto;
  padding: 7vh 0 9vh;
  text-align: center;
}

.welcome-kicker {
  margin: 0 0 18px;
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.4;
  animation: welcome-in 0.45s ease both;
}

.welcome h1 {
  margin: 0 0 10px;
  color: #191d23;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.35;
  animation: welcome-in 0.45s 0.04s ease both;
}

.welcome p {
  max-width: 480px;
  margin: 0;
  color: #858b95;
  font-size: 14px;
  line-height: 1.72;
  animation: welcome-in 0.45s 0.08s ease both;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 30px;
  animation: welcome-in 0.45s 0.12s ease both;
}

.suggestion {
  padding: 9px 15px;
  color: #5f6670;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease,
    transform 0.16s ease;
}

.suggestion:hover {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: #cdd7ff;
  transform: translateY(-1px);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 27px;
  padding: 18px 0 8px;
}

.messages:empty {
  display: none;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: message-in 0.24s ease both;
}

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

.msg.user .bubble {
  max-width: 78%;
  padding: 11px 15px;
  color: #262a31;
  background: var(--bubble);
  border-radius: 16px 16px 5px 16px;
  font-size: 15px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.assistant .msg-avatar {
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 9px;
  box-shadow: 0 2px 7px rgba(77, 107, 254, 0.16);
}

.bot-avatar {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #6f87ff, #4d6bfe);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

.msg-body {
  min-width: 0;
  max-width: calc(100% - 44px);
}

.msg.assistant .msg-body {
  flex: 1;
  padding-top: 2px;
}

.assistant-content {
  color: #272b32;
  font-size: 15px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}

.assistant-content > :first-child {
  margin-top: 0;
}

.assistant-content > :last-child {
  margin-bottom: 0;
}

.assistant-content p {
  margin: 0 0 12px;
}

.assistant-content h1,
.assistant-content h2,
.assistant-content h3 {
  margin: 22px 0 10px;
  color: #1d2127;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.assistant-content h1 { font-size: 20px; }
.assistant-content h2 { font-size: 18px; }
.assistant-content h3 { font-size: 16px; }

.assistant-content ul,
.assistant-content ol {
  margin: 8px 0 14px;
  padding-left: 23px;
}

.assistant-content li {
  margin: 4px 0;
}

.assistant-content strong {
  font-weight: 600;
  color: #1e2228;
}

.assistant-content code {
  padding: 2px 5px;
  color: #344054;
  background: #f1f3f6;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.88em;
}

.assistant-content pre {
  margin: 12px 0 14px;
  padding: 14px 16px;
  overflow-x: auto;
  background: #f7f8fa;
  border: 1px solid #e9ebef;
  border-radius: 11px;
  line-height: 1.62;
}

.assistant-content pre code {
  padding: 0;
  color: #2c3440;
  background: transparent;
  border-radius: 0;
  font-size: 12.8px;
}

.assistant-content blockquote {
  margin: 12px 0;
  padding: 2px 0 2px 13px;
  color: #5e6570;
  border-left: 3px solid #d9def0;
}

.assistant-content a {
  color: var(--brand);
  text-underline-offset: 3px;
}

.thinking-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: message-in 0.24s ease both;
}

.thinking-row .msg-avatar {
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 9px;
  box-shadow: 0 2px 7px rgba(77, 107, 254, 0.16);
}

.thinking-box {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  color: #757c87;
  font-size: 14px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #dbe2ff;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.78s linear infinite;
}

.thinking-text {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  letter-spacing: 0.01em;
}

.think-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
  padding-bottom: 1px;
}

.think-dots i {
  width: 3px;
  height: 3px;
  background: #8f96a1;
  border-radius: 50%;
  animation: dot-bounce 1.25s infinite ease-in-out;
}

.think-dots i:nth-child(2) { animation-delay: 0.16s; }
.think-dots i:nth-child(3) { animation-delay: 0.32s; }

.composer-wrap {
  flex: none;
  padding: 0 28px 16px;
  background: linear-gradient(to top, #fff 76%, rgba(255, 255, 255, 0));
}

.composer-inner {
  width: 100%;
  max-width: 764px;
  margin: 0 auto;
}

.composer {
  padding: 13px 14px 9px;
  background: #fff;
  border: 1px solid #e2e4e8;
  border-radius: 18px;
  box-shadow: 0 6px 22px rgba(17, 24, 39, 0.055), 0 1px 2px rgba(17, 24, 39, 0.025);
  transition: border-color 0.17s ease, box-shadow 0.17s ease;
}

.composer:focus-within {
  border-color: #c5d0ff;
  box-shadow: 0 8px 28px rgba(77, 107, 254, 0.1), 0 1px 2px rgba(17, 24, 39, 0.03);
}

.composer textarea {
  display: block;
  width: 100%;
  height: 26px;
  max-height: 176px;
  padding: 0 2px;
  color: #1f2329;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  font-size: 15px;
  line-height: 1.66;
  scrollbar-width: thin;
}

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

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
}

.tool-left,
.tool-right {
  display: flex;
  align-items: center;
  gap: 3px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 7px;
  color: #818791;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 12.5px;
  transition: color 0.15s ease, background 0.15s ease;
}

.tool-btn:hover {
  color: #4c535d;
  background: #f4f5f7;
}

.tool-btn.active {
  color: var(--brand);
  background: var(--brand-soft);
}

.hint {
  margin-right: 7px;
  color: #a5aab2;
  font-size: 11.5px;
  user-select: none;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(77, 107, 254, 0.26);
  transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--brand-hover);
  box-shadow: 0 3px 10px rgba(77, 107, 254, 0.32);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn:disabled {
  color: #fff;
  background: #d6d9df;
  box-shadow: none;
}

.disclaimer {
  margin: 9px 0 0;
  color: #a6abb4;
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 100;
  padding: 9px 15px;
  color: #fff;
  background: rgba(29, 34, 42, 0.9);
  border-radius: 9px;
  box-shadow: 0 7px 22px rgba(0, 0, 0, 0.16);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(8px);
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================
   Admin console
   ========================= */

.admin-body {
  height: 100dvh;
  overflow: hidden;
  background: #f3f4f7;
}

.admin-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  height: 62px;
  padding: 0 24px;
  color: #fff;
  background: #0e1117;
  border-bottom: 1px solid #1d222d;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.admin-brand-name {
  color: #f4f6fb;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.admin-brand-cn {
  color: #8e99ab;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.admin-badge {
  margin-left: 4px;
  padding: 4px 8px;
  color: #a9b9ff;
  background: rgba(77, 107, 254, 0.14);
  border: 1px solid rgba(122, 146, 255, 0.22);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.admin-top-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #a2aab8;
  font-size: 12px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: #f59e0b;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.live-indicator.online .live-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.13);
}

.live-indicator.offline .live-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.13);
}

.admin-link {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #c5d0ff;
  font-size: 12.5px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.admin-link:hover {
  color: #fff;
}

.admin-main {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  flex: 1;
  gap: 16px;
  width: 100%;
  max-width: 1460px;
  min-height: 0;
  margin: 0 auto;
  padding: 18px;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 15px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.035);
}

.conv-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex: none;
  padding: 18px 18px 15px;
  border-bottom: 1px solid #eff1f4;
}

.conv-head h2,
.admin-chat-head h2 {
  margin: 0;
  color: #1d2127;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.conv-head p,
.admin-chat-head p {
  margin: 5px 0 0;
  color: #9298a2;
  font-size: 11.5px;
  line-height: 1.4;
}

.conv-count {
  display: grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  padding: 0 6px;
  color: #687080;
  background: #f1f3f6;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
}

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

.conv-empty,
.admin-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #a0a6b0;
  text-align: center;
}

.conv-empty {
  height: 100%;
  min-height: 180px;
  padding: 24px 18px;
}

.conv-empty .icon-22 {
  margin-bottom: 10px;
  color: #b6bcc6;
}

.conv-empty p {
  margin: 0 0 5px;
  color: #727985;
  font-size: 12.5px;
  font-weight: 500;
}

.conv-empty span {
  max-width: 180px;
  font-size: 11.5px;
  line-height: 1.55;
}

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin-bottom: 3px;
  padding: 11px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.conv-item:hover {
  background: #f7f8fa;
}

.conv-item.active {
  background: #f1f4ff;
  border-color: #e0e6ff;
}

.conv-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 31px;
  height: 31px;
  color: #52617c;
  background: #edf0f5;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
}

.conv-item.active .conv-avatar {
  color: #fff;
  background: var(--brand);
}

.conv-content {
  flex: 1;
  min-width: 0;
}

.conv-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.conv-name {
  overflow: hidden;
  color: #343a43;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-time {
  flex: none;
  color: #abb0b8;
  font-size: 10.5px;
}

.conv-preview {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  overflow: hidden;
  color: #8c929c;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-dot {
  flex: none;
  width: 5px;
  height: 5px;
  background: #f59e0b;
  border-radius: 50%;
}

.chat-panel {
  position: relative;
}

.admin-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  min-height: 74px;
  padding: 15px 21px;
  border-bottom: 1px solid #eff1f4;
}

.chat-head-copy {
  min-width: 0;
}

.chat-head-copy h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-state {
  flex: none;
  padding: 5px 9px;
  color: #8b929d;
  background: #f4f5f7;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.chat-state.waiting {
  color: #b45309;
  background: #fff7ed;
}

.chat-state.replied {
  color: #15803d;
  background: #f0fdf4;
}

.admin-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 24px 26px;
  overflow-y: auto;
  background: #fcfcfd;
}

.admin-empty {
  flex: 1;
  padding: 30px;
}

.admin-empty-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 17px;
  color: #8290b9;
  background: #f2f5ff;
  border: 1px solid #e4e9ff;
  border-radius: 18px;
}

.admin-empty h3 {
  margin: 0 0 8px;
  color: #4b5361;
  font-size: 15px;
  font-weight: 600;
}

.admin-empty p {
  margin: 0;
  color: #9ba1ab;
  font-size: 12.5px;
  line-height: 1.7;
}

.admin-msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 82%;
  animation: message-in 0.22s ease both;
}

.admin-msg.user {
  align-self: flex-start;
}

.admin-msg.assistant {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.admin-msg-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.admin-msg.user .admin-msg-avatar {
  color: #596273;
  background: #e9edf3;
}

.admin-msg.assistant .admin-msg-avatar {
  color: #fff;
  background: var(--brand);
}

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

.admin-msg-label {
  margin: 0 0 4px 2px;
  color: #a0a6b0;
  font-size: 10.5px;
  font-weight: 500;
}

.admin-msg.assistant .admin-msg-label {
  margin-right: 2px;
  text-align: right;
}

.admin-msg-bubble {
  padding: 10px 13px;
  color: #303640;
  background: #fff;
  border: 1px solid #e8ebef;
  border-radius: 4px 12px 12px 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.025);
  font-size: 13px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-msg.assistant .admin-msg-bubble {
  color: #fff;
  background: #566ff0;
  border-color: #566ff0;
  border-radius: 12px 4px 12px 12px;
}

.admin-msg-time {
  margin-top: 4px;
  color: #adb2ba;
  font-size: 10px;
}

.admin-msg.assistant .admin-msg-time {
  text-align: right;
}

.pending-card {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-left: 37px;
  padding: 8px 12px;
  color: #a16207;
  background: #fffbeb;
  border: 1px solid #fdecc8;
  border-radius: 8px;
  font-size: 11.5px;
  animation: message-in 0.22s ease both;
}

.pending-card .mini-spinner {
  width: 12px;
  height: 12px;
  border: 1.7px solid #f3dfae;
  border-top-color: #d97706;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.admin-reply {
  flex: none;
  padding: 12px 18px 15px;
  background: #fff;
  border-top: 1px solid #eff1f4;
}

.reply-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 8px;
}

.reply-as {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #5d6675;
  font-size: 11.5px;
  font-weight: 500;
}

.reply-as::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--brand);
  border-radius: 50%;
}

.reply-hint {
  color: #a8adb5;
  font-size: 10.5px;
}

.reply-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 10px 10px 10px 13px;
  background: #fff;
  border: 1px solid #e1e4e9;
  border-radius: 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.reply-row:focus-within {
  border-color: #c4cfff;
  box-shadow: 0 0 0 3px rgba(77, 107, 254, 0.07);
}

.reply-row textarea {
  flex: 1;
  width: 100%;
  height: 24px;
  max-height: 140px;
  padding: 1px 0;
  color: #262b33;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  font-size: 13px;
  line-height: 1.65;
}

.reply-row textarea::placeholder {
  color: #a8adb6;
}

.reply-send {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: none;
  height: 34px;
  padding: 0 13px;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.reply-send:hover:not(:disabled) {
  background: var(--brand-hover);
}

.reply-send:disabled {
  opacity: 0.4;
}

/* =========================
   Scrollbars
   ========================= */

.chat-scroll,
.conv-list,
.admin-messages {
  scrollbar-width: thin;
  scrollbar-color: #d5d8de transparent;
}

.chat-scroll::-webkit-scrollbar,
.conv-list::-webkit-scrollbar,
.admin-messages::-webkit-scrollbar {
  width: 7px;
}

.chat-scroll::-webkit-scrollbar-thumb,
.conv-list::-webkit-scrollbar-thumb,
.admin-messages::-webkit-scrollbar-thumb {
  background: #d9dce2;
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.chat-scroll::-webkit-scrollbar-thumb:hover,
.conv-list::-webkit-scrollbar-thumb:hover,
.admin-messages::-webkit-scrollbar-thumb:hover {
  background: #c3c7cf;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* =========================
   Animations
   ========================= */

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

@keyframes dot-bounce {
  0%, 55%, 100% { opacity: 0.35; transform: translateY(0); }
  25% { opacity: 1; transform: translateY(-2px); }
}

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

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

/* =========================
   Responsive — user
   ========================= */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 272px;
    transform: translateX(-103%);
    transition: transform 0.22s ease;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  }

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

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 29;
    display: block;
    background: rgba(17, 24, 39, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .app.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: grid !important;
  }

  .topbar {
    padding: 0 16px;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: 56px;
  }

  .topbar-right .avatar {
    display: none;
  }

  .chat-inner {
    padding: 4px 16px 16px;
  }

  .welcome {
    padding: 6vh 0 8vh;
  }

  .welcome-kicker {
    margin-bottom: 15px;
    font-size: 10.5px;
  }

  .welcome h1 {
    max-width: 310px;
    font-size: 23px;
    line-height: 1.42;
  }

  .welcome p {
    max-width: 320px;
    font-size: 13px;
  }

  .suggestions {
    margin-top: 24px;
    gap: 7px;
  }

  .suggestion {
    padding: 8px 12px;
    font-size: 12px;
  }

  .messages {
    gap: 22px;
    padding-top: 10px;
  }

  .msg.user .bubble {
    max-width: 86%;
    padding: 10px 13px;
    font-size: 14.5px;
  }

  .assistant-content {
    font-size: 14.5px;
  }

  .msg.assistant .msg-avatar,
  .thinking-row .msg-avatar {
    width: 27px;
    height: 27px;
    border-radius: 8px;
  }

  .msg {
    gap: 10px;
  }

  .composer-wrap {
    padding: 0 12px max(12px, env(safe-area-inset-bottom));
  }

  .composer {
    padding: 11px 12px 8px;
    border-radius: 16px;
  }

  .composer textarea {
    font-size: 15px;
  }

  .tool-btn span {
    display: none;
  }

  .tool-btn {
    width: 30px;
    justify-content: center;
    padding: 0;
  }

  .hint {
    display: none;
  }

  .disclaimer {
    margin-top: 7px;
    font-size: 10.5px;
  }
}

@media (max-width: 390px) {
  .model-pill {
    padding: 0 9px;
    font-size: 12.5px;
  }

  .welcome h1 {
    font-size: 21px;
  }
}

/* =========================
   Responsive — admin
   ========================= */

@media (max-width: 980px) {
  .admin-main {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .admin-messages {
    padding: 20px;
  }
}

@media (max-width: 760px) {
  .admin-body {
    overflow: auto;
  }

  .admin-shell {
    min-height: 100dvh;
    height: auto;
  }

  .admin-topbar {
    height: 56px;
    padding: 0 14px;
  }

  .admin-brand-name {
    font-size: 16px;
  }

  .admin-badge {
    padding: 3px 6px;
    font-size: 10px;
  }

  .live-indicator {
    display: none;
  }

  .admin-link {
    font-size: 11.5px;
  }

  .admin-main {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 56px);
    padding: 10px;
    gap: 10px;
  }

  .conv-panel {
    flex: 0 0 auto;
    max-height: 176px;
  }

  .conv-head {
    padding: 11px 14px 10px;
  }

  .conv-head p {
    display: none;
  }

  .conv-list {
    display: flex;
    gap: 6px;
    padding: 7px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .conv-item {
    flex: 0 0 190px;
    margin-bottom: 0;
    padding: 8px;
  }

  .conv-empty {
    min-height: 88px;
    height: 88px;
    flex: 1;
    padding: 10px;
  }

  .conv-empty .icon-22 {
    display: none;
  }

  .admin-chat-head {
    min-height: 64px;
    padding: 11px 14px;
  }

  .admin-messages {
    padding: 16px 14px;
  }

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

  .admin-reply {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .reply-hint {
    display: none;
  }
}

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