:root {
  color-scheme: light;
  --bg: #eef1ea;
  --panel: rgba(248, 250, 246, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(34, 44, 34, 0.08);
  --line-strong: rgba(34, 44, 34, 0.14);
  --text: #1c241d;
  --muted: #70806f;
  --accent: #95ec69;
  --accent-deep: #66b642;
  --green-shadow: rgba(107, 179, 63, 0.22);
  --surface-shadow: 0 24px 80px rgba(70, 88, 63, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --header-height: 76px;
  --composer-height: 124px;
  --font-sans:
    "PingFang SC", "SF Pro Text", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei UI",
    "Microsoft YaHei", sans-serif;
  --font-display: "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(157, 231, 124, 0.24), transparent 26%),
    radial-gradient(circle at bottom right, rgba(255, 214, 120, 0.18), transparent 28%),
    linear-gradient(160deg, #f1f5ef 0%, #e8ece3 45%, #dde5d5 100%);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 18px 12px 20px;
  overflow: hidden;
}

.ambient {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(12px);
  opacity: 0.55;
  pointer-events: none;
}

.ambient-left {
  top: -120px;
  left: -60px;
  background: radial-gradient(circle, rgba(129, 224, 83, 0.34), transparent 68%);
}

.ambient-right {
  right: -90px;
  bottom: -80px;
  background: radial-gradient(circle, rgba(255, 193, 76, 0.26), transparent 65%);
}

.wechat-app {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - 38px);
  max-width: 1360px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 34px;
  box-shadow: var(--surface-shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px 14px;
  background: linear-gradient(180deg, rgba(248, 250, 246, 0.94), rgba(244, 247, 241, 0.92));
  border-bottom: 1px solid var(--line);
}

.sidebar-head,
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-head h1,
.chat-title-group h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-head h1 {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(34, 44, 34, 0.05);
  box-shadow: 0 12px 30px rgba(96, 112, 93, 0.1);
}

.icon-button span {
  position: absolute;
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 99px;
  background: var(--text);
}

#new-chat-button span:last-child {
  transform: rotate(90deg);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(34, 44, 34, 0.06);
  border-radius: 16px;
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
}

.search-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  background: var(--muted);
  border-radius: 999px;
  transform: rotate(45deg);
}

.mobile-session-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.mobile-session-strip::-webkit-scrollbar {
  display: none;
}

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(34, 44, 34, 0.06);
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
}

.session-chip.active {
  background: rgba(149, 236, 105, 0.24);
  border-color: rgba(107, 179, 63, 0.28);
}

.session-list {
  display: none;
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}

.session-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px 10px;
  border-radius: 18px;
  color: inherit;
  text-align: left;
  transition: background 0.18s ease, transform 0.18s ease;
}

.session-item:hover {
  background: rgba(255, 255, 255, 0.78);
}

.session-item.active {
  background: linear-gradient(135deg, rgba(149, 236, 105, 0.22), rgba(255, 255, 255, 0.95));
}

.session-main {
  min-width: 0;
}

.session-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.session-name {
  font-size: 15px;
  font-weight: 600;
}

.session-time {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.session-preview,
.session-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-unread {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff5b58;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.sidebar-foot {
  margin-top: auto;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(34, 44, 34, 0.06);
  border-radius: 18px;
}

.profile-pill strong,
.profile-pill span {
  display: block;
}

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

.avatar,
.chat-avatar,
.profile-avatar {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  border-radius: 18px;
  user-select: none;
}

.avatar {
  width: 48px;
  height: 48px;
  font-size: 20px;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.avatar-emerald {
  background: linear-gradient(140deg, #38c27d, #1d9a60);
}

.avatar-ocean {
  background: linear-gradient(140deg, #3b7bff, #2c56d2);
}

.avatar-amber {
  background: linear-gradient(140deg, #f5b14a, #dd7d22);
}

.avatar-plum {
  background: linear-gradient(140deg, #8b65f7, #5d39c8);
}

.avatar-slate {
  background: linear-gradient(140deg, #6d7f8d, #465362);
}

.avatar-self {
  background: linear-gradient(140deg, #5fbf44, #399b2e);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(247, 249, 244, 0.94), rgba(240, 243, 236, 0.96)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.2));
}

.chat-header {
  height: var(--header-height);
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 246, 0.78);
  backdrop-filter: blur(12px);
}

.back-chip {
  min-width: 64px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(34, 44, 34, 0.06);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-title-group h2 {
  font-size: 18px;
}

.chat-title-group p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-button-plain {
  gap: 4px;
}

.icon-button-plain .dot {
  position: static;
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

.message-stage {
  position: relative;
  overflow: hidden;
  padding: 14px 14px 20px;
}

.message-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(72, 89, 70, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(72, 89, 70, 0.032) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, 0.5) 12%, rgba(0, 0, 0, 1) 100%);
  pointer-events: none;
}

.message-date-chip {
  position: relative;
  z-index: 1;
  width: fit-content;
  margin: 0 auto 14px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 6px 20px rgba(106, 117, 93, 0.1);
}

.message-list {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: calc(100vh - var(--header-height) - var(--composer-height) - 90px);
  min-height: 300px;
  overflow: auto;
  padding: 4px 2px 0;
}

.message-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: bubble-in 0.28s ease;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-row.outgoing .avatar {
  display: none;
}

.message-row.outgoing .bubble {
  border-bottom-right-radius: 6px;
}

.message-row.incoming .bubble {
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.95);
}

.bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(82%, 380px);
}

.bubble {
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(66, 101, 48, 0.12);
  word-break: break-word;
  line-height: 1.5;
}

.bubble-meta {
  color: var(--muted);
  font-size: 11px;
}

.message-row.outgoing .bubble-meta {
  text-align: right;
}

.typing-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 8px;
  animation: fade-up 0.22s ease;
}

.typing-avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
  border-radius: 14px;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(88, 99, 83, 0.08);
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(115, 128, 113, 0.74);
  animation: pulse 1s infinite ease-in-out;
}

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

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

.composer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: rgba(248, 250, 246, 0.84);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.composer-tools {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.composer-tools::-webkit-scrollbar {
  display: none;
}

.composer-tool {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(34, 44, 34, 0.06);
  color: var(--text);
  font-size: 13px;
}

.composer-input-wrap {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: end;
}

.plus-button,
.send-button {
  height: 48px;
  border-radius: 16px;
  font-weight: 700;
}

.plus-button {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(34, 44, 34, 0.06);
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
}

.send-button {
  min-width: 76px;
  padding: 0 16px;
  background: linear-gradient(180deg, #a0ef75, #8adb5e);
  color: #143008;
  box-shadow: 0 18px 32px var(--green-shadow);
}

.send-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

textarea {
  width: 100%;
  min-height: 48px;
  max-height: 144px;
  padding: 12px 14px;
  resize: none;
  outline: none;
  border: 1px solid rgba(34, 44, 34, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  line-height: 1.5;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: scale(0.75);
    opacity: 0.7;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding: 32px;
  }

  .wechat-app {
    grid-template-columns: 320px 1fr;
    min-height: calc(100vh - 64px);
  }

  .sidebar {
    gap: 18px;
    padding: 20px;
    border-right: 1px solid var(--line);
    border-bottom: none;
  }

  .mobile-session-strip {
    display: none;
  }

  .session-list {
    display: flex;
    flex-direction: column;
  }

  .chat-header,
  .composer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .message-stage {
    padding-left: 20px;
    padding-right: 20px;
  }

  .message-list {
    height: calc(100vh - var(--header-height) - var(--composer-height) - 120px);
  }

  .back-chip {
    display: none;
  }
}

@media (max-width: 899px) {
  .sidebar-foot,
  .search-bar {
    display: none;
  }

  .sidebar {
    gap: 14px;
  }

  .sidebar-head {
    padding: 4px 2px 0;
  }

  .sidebar-head h1 {
    font-size: 24px;
  }

  .chat-panel {
    min-height: 72vh;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  .wechat-app {
    min-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .sidebar {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .chat-header {
    padding-top: max(14px, env(safe-area-inset-top));
  }

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

  .message-list {
    height: calc(100vh - var(--header-height) - var(--composer-height) - 80px);
  }

  .composer-input-wrap {
    grid-template-columns: 44px 1fr 72px;
    gap: 8px;
  }

  .plus-button,
  .send-button {
    height: 44px;
  }
}
