:root {
  --ink: #1a1208;
  --ink-soft: #3d2f1a;
  --ink-faint: #7a6a50;
  --rice: #faf6ee;
  --parchment: #f0e8d5;
  --parchment2: #e8dcca;
  --jade: #b8872a;
  --jade-light: #d4a84b;
  --jade-glow: rgb(250, 236, 216);
  --gold: #b8872a;
  --gold-light: #d4a84b;
  --cinnabar: #c0392b;
  --sidebar-w: 300px;
  --radius: 12px;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  font-family: 'Noto Sans SC', 'PingFang SC', sans-serif;
  background: var(--rice);
  color: var(--ink);
  overflow: hidden;
}
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--parchment2);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-faint);
}
.app {
  display: flex;
  height: 100vh;
  position: relative;
}
.app::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(ellipse 800px 600px at 20% 80%, rgba(46, 107, 80, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 600px 400px at 80% 20%, rgba(184, 135, 42, 0.05) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='%23faf6ee'/%3E%3Ccircle cx='1' cy='1' r='.4' fill='%23e8dcca' opacity='.5'/%3E%3C/svg%3E");
  pointer-events: none;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #1e1409 0%, #2a1e0c 100%);
  border-right: 1px solid rgba(184, 135, 42, 0.2);
  position: relative;
  z-index: 10;
  transition: transform var(--transition);
}
.sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(212, 168, 75, 0.4) 30%,
    rgba(212, 168, 75, 0.4) 70%,
    transparent
  );
  pointer-events: none;
}
.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(184, 135, 42, 0.15);
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--jade) 0%, var(--jade-light) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.logo-text {
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-size: 20px;
  color: var(--gold-light);
  letter-spacing: 0.1em;
  line-height: 1.2;
}
.logo-sub {
  font-size: 10px;
  color: rgba(212, 168, 75, 0.45);
  letter-spacing: 0.2em;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 300;
}
.new-chat-btn {
  width: 100%;
  padding: 5px 18px;
  background: linear-gradient(135deg, var(--jade) 0%, var(--jade-light) 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  letter-spacing: 0.05em;
}
.new-chat-btn svg {
  flex-shrink: 0;
}
.conv-section-label {
  padding: 16px 24px 8px;
  font-size: 10px;
  color: rgba(212, 168, 75, 0.4);
  letter-spacing: 0.25em;
  font-weight: 500;
  text-transform: uppercase;
}
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px;
}
.conv-item {
  padding: 11px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 3px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}
.conv-item:hover {
  background: rgba(212, 168, 75, 0.08);
}
.conv-item.active {
  background: rgba(225, 225, 67, 0.2);
}
.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 30%;
  background: var(--jade-light);
  border-radius: 0 2px 2px 0;
}
.conv-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.6;
}
.conv-info {
  flex: 1;
  min-width: 0;
}
.conv-title {
  font-size: 13px;
  color: rgba(250, 246, 238, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.conv-time {
  font-size: 10px;
  color: rgba(250, 246, 238, 0.3);
  margin-top: 2px;
}
.conv-item.active .conv-title {
  color: rgba(250, 246, 238, 0.95);
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(184, 135, 42, 0.1);
  font-size: 11px;
  color: rgba(250, 246, 238, 0.2);
  text-align: center;
  letter-spacing: 0.05em;
}
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.chat-header {
  padding: 18px 32px;
  border-bottom: 1px solid rgba(26, 18, 8, 0.08);
  background: rgba(250, 246, 238, 0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 5;
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-faint);
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.menu-btn:hover {
  background: var(--parchment);
  color: var(--ink);
}
.chat-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.chat-subtitle {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  margin-top: 1px;
}
.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--jade-glow);
  border: 1px solid var(--jade-light);
  border-radius: 20px;
  font-size: 11px;
  color: var(--jade);
  letter-spacing: 0.04em;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jade-light);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
}
.welcome-symbol {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 72px;
  color: var(--jade);
  opacity: 0.15;
  margin-bottom: -16px;
  line-height: 1;
  user-select: none;
}
.welcome-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 28px;
  font-weight: 300;
  color: var(--ink-soft);
  letter-spacing: 0.15em;
  margin-bottom: 10px;
}
.welcome-desc {
  font-size: 14px;
  color: var(--ink-faint);
  line-height: 1.8;
  max-width: 420px;
  letter-spacing: 0.04em;
}
.welcome-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 28px 0 20px;
  width: 100%;
  max-width: 480px;
}
.welcome-divider::before,
.welcome-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--parchment2), transparent);
}
.welcome-divider span {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 520px;
}
.suggestion-card {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(26, 18, 8, 0.07);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}
.suggestion-card:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--jade-light);
  transform: translateY(-2px);
}
.suggestion-card .card-icon {
  font-size: 18px;
  margin-bottom: 6px;
}
.suggestion-card .card-text {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  letter-spacing: 0.02em;
}
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}
.messages-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.msg {
  display: flex;
  gap: 12px;
  animation: msgIn 0.3s ease both;
}
@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.msg.user {
  flex-direction: row-reverse;
}
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}
.msg-avatar img {
  border-radius: 50%;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, #b8872a, #d4a84b);
  color: #fff;
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
}
.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--jade), var(--jade-light));
  color: #fff;
}
.msg-body {
  max-width: 72%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg.user .msg-body {
  align-items: flex-end;
}
.msg-bubble {
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: 0.03em;
  position: relative;
}
.msg.user .msg-bubble {
  background: #cea144;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant .msg-bubble {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(26, 18, 8, 0.07);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(4px);
}
.msg-time {
  font-size: 10px;
  color: var(--ink-faint);
  padding: 0 4px;
  letter-spacing: 0.04em;
}
.msg-bubble h1,
.msg-bubble h2,
.msg-bubble h3 {
  font-family: 'Noto Serif SC', serif;
  color: var(--jade);
  margin: 0.8em 0 0.4em;
  letter-spacing: 0.05em;
}
.msg-bubble h1 {
  font-size: 18px;
}
.msg-bubble h2 {
  font-size: 16px;
  border-bottom: 1px solid rgba(46, 107, 80, 0.15);
  padding-bottom: 4px;
}
.msg-bubble h3 {
  font-size: 14px;
  color: var(--jade-light);
}
.msg-bubble p {
  margin: 0.4em 0;
}
.msg-bubble ul,
.msg-bubble ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}
.msg-bubble li {
  margin: 0.2em 0;
}
.msg-bubble strong {
  color: var(--gold);
  font-weight: 600;
}
.msg-bubble em {
  color: var(--jade);
  font-style: normal;
}
.msg-bubble code {
  font-family: 'Courier New', monospace;
  background: rgba(46, 107, 80, 0.08);
  color: var(--jade);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid rgba(46, 107, 80, 0.15);
}
.msg-bubble pre {
  background: rgba(26, 18, 8, 0.04);
  border: 1px solid rgba(26, 18, 8, 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.6em 0;
}
.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
}
.msg-bubble blockquote {
  border-left: 3px solid var(--jade-light);
  padding: 4px 12px;
  margin: 0.6em 0;
  background: var(--jade-glow);
  border-radius: 0 6px 6px 0;
  color: var(--ink-soft);
  font-style: italic;
}
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.6em 0;
  font-size: 13px;
}
.msg-bubble th {
  background: rgba(46, 107, 80, 0.08);
  padding: 7px 12px;
  text-align: left;
  color: var(--jade);
  font-weight: 500;
  border: 1px solid rgba(26, 18, 8, 0.08);
}
.msg-bubble td {
  padding: 6px 12px;
  border: 1px solid rgba(26, 18, 8, 0.06);
}
.msg-bubble tr:nth-child(even) td {
  background: rgba(26, 18, 8, 0.02);
}
.msg-bubble hr {
  border: none;
  border-top: 1px solid rgba(26, 18, 8, 0.1);
  margin: 0.8em 0;
}
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jade-light);
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
  background: var(--gold);
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
.input-area {
  flex-shrink: 0;
  padding: 16px 32px 24px;
  background: rgba(250, 246, 238, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(26, 18, 8, 0.07);
  position: relative;
  z-index: 5;
}
.input-wrap {
  max-width: 800px;
  margin: 0 auto;
}
.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px 10px 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(26, 18, 8, 0.1);
  border-radius: 16px;
  transition: var(--transition);
  backdrop-filter: blur(4px);
}
.input-box:focus-within {
  border-color: var(--jade-light);
}
.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 14px;
  color: var(--ink);
  resize: none;
  line-height: 1.6;
  max-height: 160px;
  overflow-y: auto;
  letter-spacing: 0.02em;
  padding: 4px 0;
}
.input-box textarea::placeholder {
  color: var(--ink-faint);
}
.send-btn {
  width: 25px;
  height: 25px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--jade), var(--jade-light));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.send-btn:disabled {
  background: var(--parchment2);
  color: var(--ink-faint);
  cursor: not-allowed;
}
.send-btn.stop {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
}
.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
}
.input-hint {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.char-count {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.char-count.warn {
  color: var(--cinnabar);
}
.ornament {
  text-align: center;
  padding: 12px;
  font-family: 'Ma Shan Zheng', serif;
  color: rgba(46, 107, 80, 0.1);
  font-size: 22px;
  letter-spacing: 0.3em;
  user-select: none;
  flex-shrink: 0;
}
.toast-wrap {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  letter-spacing: 0.03em;
  animation: toastIn 0.3s ease both;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 280px;
}
.toast.success {
  background: var(--jade);
  color: #fff;
}
.toast.error {
  background: var(--cinnabar);
  color: #fff;
}
.toast.info {
  background: var(--ink-soft);
  color: #fff;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--rice);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: opacity 0.4s ease;
}
.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
}
.loader-inner {
  text-align: center;
}
.loader-symbol {
  font-family: 'Ma Shan Zheng', serif;
  font-size: 52px;
  color: var(--jade);
  animation: breathe 2s ease-in-out infinite;
  display: block;
  margin-bottom: 12px;
}
@keyframes breathe {
  0%,
  100% {
    opacity: 0.5;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}
.loader-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.2em;
}
.no-conv-hint {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 14px;
  letter-spacing: 0.04em;
}
.no-conv-hint .hint-icon {
  font-size: 36px;
  opacity: 0.4;
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-btn {
    display: flex;
  }
  .main {
    width: 100%;
  }
  .messages-inner {
    padding: 0 16px;
  }
  .input-area {
    padding: 12px 16px 20px;
  }
  .suggestion-grid {
    grid-template-columns: 1fr;
  }
  .chat-header {
    padding: 14px 20px;
  }
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    display: none;
    backdrop-filter: blur(2px);
  }
  .overlay.show {
    display: block;
  }
}
#tcmModalRoot {
  position: fixed;
  inset: 0;
  z-index: 20000;
}
.tcm-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(26, 18, 8, 0.6);
  backdrop-filter: blur(16px);
}
.tcm-modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tcm-modal-card {
  width: 100%;
  max-width: 460px;
  background: rgba(250, 246, 238, 0.95);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid rgba(26, 18, 8, 0.08);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
  animation: tcmFadeIn 0.25s ease;
}
@keyframes tcmFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.tcm-title {
  font-size: 18px;
  margin-bottom: 12px;
  color: var(--ink);
}
.tcm-text {
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.7;
  margin-bottom: 10px;
}
.tcm-warning {
  color: var(--cinnabar);
  font-weight: 500;
}
.tcm-qq {
  margin-top: 10px;
  padding: 10px;
  background: var(--jade-glow);
  border-radius: 10px;
  font-size: 12px;
}
.tcm-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.tcm-btn {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  font-size: 13px;
}
.tcm-btn.accept {
  background: var(--jade-light);
  color: #fff;
}
.tcm-btn.reject {
  background: rgba(0, 0, 0, 0.06);
}
.tcm-hidden {
  display: none;
}
@media (max-width: 480px) {
  .tcm-modal-card {
    padding: 18px;
  }
}
