:root {
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "PingFang SC", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202428;
  background: #ffffff;
  font-size: 15px;
  --accent: #0b756e;
  --accent-hover: #09645e;
  --ink: #202428;
  --muted: #737a81;
  --line: #e5e8e8;
  --panel: #f6f7f7;
  --soft: #edf1f0;
  --danger: #b34235;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #ffffff;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.login-view {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 96px 24px 72px;
  background: #ffffff;
}

.login-brand {
  position: absolute;
  top: 26px;
  left: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #34393d;
  font-size: 14px;
  font-weight: 650;
}

.login-brand-logo,
.brand-logo,
.login-logo,
.welcome-logo,
.assistant-avatar img {
  display: block;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
}

.login-brand-logo {
  width: 32px;
  height: 32px;
}

.login-content {
  width: min(410px, 100%);
  text-align: center;
}

.login-logo {
  width: 82px;
  height: 82px;
  margin: 0 auto 20px;
}

.login-content h1 {
  margin: 0;
  color: #1f2428;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-subtitle {
  color: #98a0a4;
  font-weight: 600;
}

.login-subtitle {
  margin-top: 8px;
  color: #4c555a;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.login-content > p {
  margin: 9px 0 34px;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  text-align: left;
  margin-top: 76px;
}

.login-form label {
  color: #444b50;
  font-size: 13px;
  font-weight: 700;
  margin-top: 6px;
}

.login-form input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  border: 1px solid #cfd4d5;
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.login-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 117, 110, 0.12);
}

.captcha-widget { display: grid; gap: 9px; }
.captcha-track { position: relative; width: 100%; min-width: 240px; height: 46px; overflow: hidden; border: 1px solid #c6dedb; border-radius: 7px; background: #f1f7f5; touch-action: none; }
.captcha-track.verified { border-color: #2f896d; background: #dff2e9; }
.captcha-track.shake { animation: captcha-shake 420ms ease-in-out; }
.captcha-target { position: absolute; top: 6px; bottom: 6px; width: 36px; border: 1px dashed #357d74; border-radius: 5px; background: rgba(53, 125, 116, 0.28); transform: translateX(-50%); }
.captcha-progress { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(11, 117, 110, 0.12); pointer-events: none; }
.captcha-handle { position: absolute; top: 3px; left: 0; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid var(--accent); border-radius: 6px; color: #fff; background: var(--accent); font-size: 19px; line-height: 1; cursor: grab; touch-action: none; user-select: none; transition: background 150ms ease, border-color 150ms ease; }
.captcha-handle:active { cursor: grabbing; }
.captcha-handle:disabled { cursor: not-allowed; opacity: .72; }
.captcha-handle:focus-visible { outline: 3px solid rgba(11, 117, 110, 0.25); outline-offset: 2px; }
.captcha-handle.verified { border-color: #2f896d; background: #2f896d; }
.captcha-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; color: #7b898b; font-size: 12px; }
.captcha-meta.verified { color: var(--accent); font-weight: 700; }
@keyframes captcha-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.primary-button {
  width: 100%;
  height: 52px;
  margin-top: 12px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
  transition: background 150ms ease;
}

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

.primary-button:disabled {
  background: #9aa6a5;
  cursor: wait;
}

.error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.login-note {
  position: absolute;
  bottom: 25px;
  left: 24px;
  right: 24px;
  text-align: center;
  color: #92989d;
  font-size: 12px;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar-top {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 7px 8px;
}

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

.brand-logo {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  mix-blend-mode: multiply;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-copy strong {
  overflow: hidden;
  color: #2b3034;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.icon-button {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #555d63;
  font-size: 20px;
  cursor: pointer;
}

.icon-button:hover {
  background: #e6e9e9;
  color: #22272b;
}

.assistant-switch {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin: 7px 0 12px;
  padding: 3px;
  border-radius: 8px;
  background: #e8ebeb;
}

.assistant-tab {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #687076;
  font-size: 13px;
  cursor: pointer;
}

.assistant-tab:hover {
  color: #30363a;
}

.assistant-tab.active {
  background: #ffffff;
  color: #202428;
  font-weight: 650;
  box-shadow: 0 1px 3px rgba(28, 37, 42, 0.08);
}

.new-chat {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid #d8dddd;
  border-radius: 7px;
  background: #ffffff;
  color: #2a3034;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.new-chat:hover {
  border-color: #c4cccb;
  background: #fcfdfd;
}

.new-chat:disabled {
  border-color: transparent;
  background: #eceeee;
  color: #9aa0a4;
  cursor: not-allowed;
}

.new-chat-icon {
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
}

.section-label {
  padding: 22px 10px 8px;
  color: #92989d;
  font-size: 11px;
}

.section-toggle {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 10px 5px;
  border: 0;
  background: transparent;
  color: #92989d;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.section-toggle:hover {
  color: #5f696f;
}

.section-toggle-icon {
  width: 18px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #9ca5a8;
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
  transition: color 160ms ease;
}

.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.conversation-list.collapsed {
  visibility: hidden;
}

.conversation {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 11px;
  border-radius: 6px;
  color: #3f464b;
  font-size: 13px;
  cursor: pointer;
}

.conversation:hover {
  background: #e9ecec;
}

.conversation.active {
  background: #e1e6e5;
  color: #1f2529;
}

.conversation-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.conversation-delete {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #8a9196;
  font-size: 17px;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
}

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

.conversation-delete:hover {
  background: #d8dddd;
  color: var(--danger);
}

.empty-list {
  padding: 13px 10px;
  color: #969ca1;
  font-size: 13px;
}

.sidebar-bottom {
  padding-top: 10px;
  border-top: 1px solid #e0e4e4;
}

.account {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #315b73;
  color: #ffffff;
  font-size: 13px;
  font-weight: 650;
}

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

.account-copy strong {
  overflow: hidden;
  color: #30363a;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.account-copy span {
  color: #8b9297;
  font-size: 11px;
}

.logout-button {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #666e74;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.logout-button:hover {
  background: #e8ebeb;
  color: #31373b;
}

.logout-button span {
  display: inline-block;
  margin-right: 8px;
  font-size: 15px;
}

.chat {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) auto;
  background: #ffffff;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 26px;
  border-bottom: 1px solid #f0f1f1;
}

.chat-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-title strong {
  overflow: hidden;
  color: #30363a;
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2d9a6e;
}

.status-dot.pending {
  background: #b37a36;
}

.status-text {
  color: #868d92;
  font-size: 12px;
}

.messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 30px 24px 44px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.messages > * {
  width: min(820px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.welcome {
  min-height: max(320px, calc(100vh - 300px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.welcome-logo {
  width: 60px;
  height: 60px;
  margin-bottom: 18px;
}

.welcome h2 {
  margin: 0;
  color: #252b2f;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0;
}

.welcome p {
  margin: 9px 0 0;
  color: #8b9297;
  font-size: 13px;
}

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  margin-bottom: 30px;
}

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

.msg-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 650;
}

.assistant-avatar {
  background: #f6f7f7;
}

.assistant-avatar img {
  width: 100%;
  height: 100%;
}

.user-avatar {
  order: 2;
  background: #315b73;
  color: #ffffff;
}

.msg-content {
  max-width: min(730px, calc(100% - 45px));
  color: #282e32;
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.msg-row.user .msg-content {
  padding: 11px 16px;
  border-radius: 18px;
  background: #eef2f2;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content h1,
.msg-content h2,
.msg-content h3 {
  margin: 16px 0 8px;
  color: #202428;
  line-height: 1.35;
  font-weight: 700;
}

.msg-content h1 { font-size: 20px; }
.msg-content h2 { font-size: 17px; }
.msg-content h3 { font-size: 15px; }

.msg-content ul,
.msg-content ol {
  margin: 8px 0 12px;
  padding-left: 24px;
}

.msg-content li {
  margin: 4px 0;
  padding-left: 3px;
}

.msg-content blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid #c8d4d2;
  color: #667176;
  background: #f6f8f8;
}

.msg-content strong {
  font-weight: 680;
}

.msg-content code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f0f2f2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.msg-content pre {
  margin: 11px 0;
  padding: 14px 15px;
  overflow: auto;
  border: 1px solid #e1e5e5;
  border-radius: 7px;
  background: #f5f7f7;
  white-space: pre;
}

.pending {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #7c8489;
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
}

.thinking-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8b9297;
  animation: thinking 1.1s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes thinking {
  0%, 65%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  width: min(900px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 18px;
}

.composer-box {
  min-height: 116px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 15px 14px 11px 17px;
  border: 1px solid #cfd5d5;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(34, 46, 50, 0.09);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer-box:focus-within {
  border-color: #91aaa7;
  box-shadow: 0 6px 22px rgba(34, 46, 50, 0.12);
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 220px;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #252b2f;
  font-size: 15px;
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #969da2;
}

.composer textarea:disabled {
  color: #9da3a7;
  cursor: not-allowed;
}

.composer-actions {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.composer-assistant {
  overflow: hidden;
  color: #858d92;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.send-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.send-button span {
  display: block;
  transform: translateY(-1px);
}

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

.send-button:disabled {
  background: #c9cecf;
  color: #ffffff;
  cursor: not-allowed;
  transform: none;
}

.composer.unavailable .composer-box {
  border-style: dashed;
  background: #fafbfb;
  box-shadow: none;
}

.composer-hint {
  margin-top: 9px;
  color: #989fa4;
  font-size: 11px;
  text-align: center;
}

.table-wrap {
  max-width: 100%;
  margin: 13px 0;
  overflow-x: auto;
}

.msg-content table {
  width: max-content;
  min-width: 440px;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.msg-content th,
.msg-content td {
  padding: 8px 12px;
  border: 1px solid #d9dede;
  text-align: left;
  white-space: nowrap;
}

.msg-content th {
  background: #f2f5f4;
  font-weight: 680;
}

.msg-content tr:nth-child(even) td {
  background: #fafbfb;
}

.mobile-only,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 760px) {
  .login-view {
    padding: 88px 22px 68px;
  }

  .login-brand {
    top: 20px;
    left: 20px;
  }

  .login-logo {
    width: 68px;
    height: 68px;
  }

  .login-content h1 {
    font-size: 26px;
  }

  .login-form {
    margin-top: 58px;
  }

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

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(310px, 88vw);
    transform: translateX(-102%);
    box-shadow: 6px 0 24px rgba(24, 31, 35, 0.16);
    transition: transform 180ms ease;
  }

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

  .app.sidebar-open .sidebar-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    display: block;
    background: rgba(22, 27, 30, 0.38);
  }

  .mobile-only {
    display: grid;
  }

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

  .messages {
    padding: 22px 14px 34px;
  }

  .welcome {
    min-height: max(280px, calc(100vh - 285px));
  }

  .welcome-logo {
    width: 52px;
    height: 52px;
  }

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

  .msg-row {
    gap: 9px;
    margin-bottom: 24px;
  }

  .msg-avatar {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .msg-content {
    max-width: calc(100% - 39px);
    font-size: 14px;
  }

  .composer {
    width: calc(100% - 22px);
    padding-bottom: max(11px, env(safe-area-inset-bottom));
  }

  .composer-box {
    min-height: 104px;
    padding: 13px 12px 10px 14px;
    border-radius: 14px;
  }

  .composer textarea {
    min-height: 48px;
    font-size: 14px;
  }

  .composer-hint {
    font-size: 10px;
  }
}

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