:root {
  --ink: #172728;
  --muted: #6d7b78;
  --paper: #f7f3eb;
  --paper-deep: #eee8dc;
  --pine: #163c3b;
  --pine-soft: #285956;
  --snow: #fffdf8;
  --line: rgba(22, 60, 59, 0.12);
  --user: #245b57;
  --danger: #9b4337;
  --shadow: 0 24px 70px rgba(28, 49, 45, 0.2);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.9), transparent 35%),
    linear-gradient(145deg, #e7eee9 0%, var(--paper) 45%, #e9dfd1 100%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.login-shell {
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  padding: 28px 18px;
}

.snow-glow {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.8) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 30% 80%, rgba(255, 255, 255, 0.8) 0 2px, transparent 3px);
  background-size: 95px 95px, 121px 121px, 147px 147px;
  opacity: 0.65;
  animation: drift 22s linear infinite;
}

.login-card {
  position: relative;
  width: min(100%, 430px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 32px;
  padding: 42px 32px 28px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--snow);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent),
    var(--pine);
  font-family: "Songti SC", "STSong", serif;
}

.mark {
  width: 64px;
  height: 64px;
  margin-bottom: 28px;
  border-radius: 20px;
  font-size: 29px;
  box-shadow: 0 12px 30px rgba(22, 60, 59, 0.24);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--pine-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.login-card h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(42px, 13vw, 58px);
  font-weight: 600;
  line-height: 1.1;
}

.login-copy {
  margin: 12px 0 34px;
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.password-row input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.password-row input:focus {
  border-color: var(--pine-soft);
  box-shadow: 0 0 0 4px rgba(40, 89, 86, 0.1);
}

.primary {
  border: 0;
  border-radius: 14px;
  background: var(--pine);
  color: var(--snow);
  padding: 0 20px;
  font-weight: 600;
}

.form-error {
  min-height: 20px;
  margin: 10px 2px 0;
  color: var(--danger);
  font-size: 12px;
}

.fine-print {
  margin: 26px 0 0;
  color: #89918e;
  font-size: 11px;
  line-height: 1.7;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  width: min(100%, 820px);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(rgba(247, 243, 235, 0.91), rgba(247, 243, 235, 0.95)),
    radial-gradient(circle at 50% 10%, #d5e5e0, transparent 44%);
}

.topbar {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.88);
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  backdrop-filter: blur(18px);
}

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

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  font-size: 20px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-row h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
  font-weight: 600;
}

.identity p {
  overflow: hidden;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-badge {
  border: 1px solid rgba(40, 89, 86, 0.2);
  border-radius: 999px;
  color: var(--pine-soft);
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.top-actions {
  display: flex;
  gap: 3px;
}

.icon-button,
.attach-button,
.send-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  background: transparent;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.icon-button svg,
.attach-button svg,
.send-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.notice {
  border-bottom: 1px solid rgba(155, 67, 55, 0.13);
  background: #fff4e5;
  color: #7c4b2f;
  padding: 10px 18px;
  font-size: 12px;
  line-height: 1.55;
}

.messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 18px 18px;
  scroll-behavior: smooth;
}

.welcome {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14vh auto 0;
  color: #89938f;
  font-family: "Songti SC", "STSong", serif;
  font-size: 13px;
  text-align: center;
}

.welcome p {
  max-width: 250px;
  margin: 0;
  line-height: 1.8;
}

.welcome-line {
  width: 28px;
  height: 1px;
  flex: 0 0 auto;
  background: var(--line);
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 14px;
  animation: rise 180ms ease-out both;
}

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

.mini-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--pine);
  color: var(--snow);
  font-family: "Songti SC", "STSong", serif;
  font-size: 12px;
}

.bubble {
  max-width: min(76%, 560px);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 5px;
  background: var(--snow);
  box-shadow: 0 5px 18px rgba(20, 36, 34, 0.05);
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user .bubble {
  border-color: transparent;
  border-radius: 18px 18px 5px 18px;
  background: var(--user);
  color: #fff;
}

.bubble .image-tag {
  display: block;
  margin-top: 7px;
  opacity: 0.65;
  font-size: 10px;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 16px 18px;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #8b9995;
  animation: bounce 1.2s infinite;
}

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

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

.composer-area {
  z-index: 2;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  padding: 9px 12px calc(7px + env(safe-area-inset-bottom));
  backdrop-filter: blur(18px);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.8);
  padding: 5px;
}

.composer textarea {
  width: 100%;
  max-height: 128px;
  min-height: 38px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 4px 8px;
  font-size: 15px;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #9aa39f;
}

.attach-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--muted);
}

.attach-button:hover {
  background: var(--paper-deep);
}

.send-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pine);
  color: white;
  transition: opacity 140ms ease, transform 140ms ease;
}

.send-button:active {
  transform: scale(0.94);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.image-preview {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 2px 0 8px 48px;
}

.image-preview img {
  width: 100%;
  height: 100%;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 5px 16px rgba(21, 44, 40, 0.15);
}

.image-preview button {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid var(--snow);
  border-radius: 50%;
  background: var(--ink);
  color: white;
  line-height: 1;
}

.safety-note {
  margin: 6px 6px 0;
  color: #9a9f9c;
  font-size: 9px;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 36px);
  transform: translate(-50%, 12px);
  border-radius: 12px;
  background: rgba(24, 38, 37, 0.9);
  color: white;
  padding: 9px 14px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@keyframes drift {
  to {
    transform: translate3d(-40px, 70px, 0);
  }
}

@keyframes rise {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}

@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (min-width: 821px) {
  .chat-shell {
    margin: 20px auto;
    height: calc(100dvh - 40px);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 28px;
    box-shadow: var(--shadow);
  }

  .topbar {
    border-radius: 28px 28px 0 0;
  }
}

@media (max-width: 420px) {
  .login-card {
    padding: 34px 24px 24px;
  }

  .messages {
    padding-inline: 13px;
  }

  .bubble {
    max-width: 82%;
  }
}

@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;
  }
}

/* WeChat-inspired chat surface */
:root {
  --ink: #111111;
  --muted: #7b7b7b;
  --paper: #ededed;
  --paper-deep: #e3e3e3;
  --pine: #07c160;
  --pine-soft: #078c49;
  --snow: #ffffff;
  --line: #d9d9d9;
  --user: #95ec69;
  --danger: #d23c32;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

body {
  background: #d8d8d8;
}

.login-shell {
  background: #ededed;
}

.snow-glow {
  display: none;
}

.login-card {
  border: 0;
  border-radius: 8px;
  padding: 38px 30px 28px;
  background: #ffffff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
  backdrop-filter: none;
}

.mark {
  border-radius: 8px;
  background: #07c160;
  box-shadow: none;
  font-family: inherit;
}

.eyebrow {
  display: none;
}

.login-card h1 {
  font-family: inherit;
  font-size: 34px;
  font-weight: 600;
}

.login-copy {
  margin-top: 9px;
}

.password-row input {
  border-radius: 5px;
  background: #f7f7f7;
}

.password-row input:focus {
  border-color: #07c160;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
}

.primary {
  border-radius: 5px;
  background: #07c160;
}

.chat-shell {
  width: min(100%, 760px);
  border-radius: 0;
  background: #ededed;
  grid-template-rows: auto 1fr auto;
}

.chat-shell:has(.notice:not(.is-hidden)) {
  grid-template-rows: auto auto 1fr auto;
}

.topbar {
  min-height: 56px;
  border-bottom-color: #d7d7d7;
  background: rgba(237, 237, 237, 0.97);
  padding: calc(9px + env(safe-area-inset-top)) 14px 9px;
  backdrop-filter: blur(14px);
}

.identity {
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 55%),
    #3c9d78;
  font-family: inherit;
  font-size: 18px;
}

.name-row {
  gap: 6px;
}

.name-row h1 {
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
}

.identity p {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: #666666;
  font-size: 10px;
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #07c160;
}

.ai-badge {
  border: 0;
  background: rgba(7, 193, 96, 0.1);
  color: #078c49;
  padding: 1px 5px;
  font-size: 8px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  color: #333333;
}

.icon-button:hover {
  background: #e1e1e1;
  color: #111111;
}

.notice {
  border-bottom-color: #dedede;
  background: #fff8dc;
  color: #7d641c;
}

.messages {
  padding: 10px 14px 22px;
  background: #ededed;
}

.welcome {
  justify-content: center;
  margin-top: 24vh;
  color: #8b8b8b;
  font-family: inherit;
  font-size: 12px;
}

.welcome p {
  max-width: 270px;
  border-radius: 4px;
  background: #d8d8d8;
  padding: 5px 10px;
  line-height: 1.6;
}

.welcome-line {
  display: none;
}

.time-divider {
  margin: 14px 0 16px;
  color: #999999;
  font-size: 10px;
  text-align: center;
}

.message-row {
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 18px;
  animation-duration: 140ms;
}

.mini-avatar {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 55%),
    #3c9d78;
  font-family: inherit;
  font-size: 14px;
}

.message-row.user .mini-avatar {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.26), transparent 55%),
    #6f8fa8;
}

.bubble {
  position: relative;
  max-width: min(68%, 470px);
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  padding: 10px 12px;
  background: #ffffff;
  color: #111111;
  font-size: 16px;
  line-height: 1.58;
}

.assistant .bubble::before {
  position: absolute;
  top: 13px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-right: 7px solid #ffffff;
  border-bottom: 6px solid transparent;
  content: "";
}

.user .bubble {
  border: 0;
  border-radius: 4px;
  background: #95ec69;
  color: #111111;
}

.user .bubble::after {
  position: absolute;
  top: 13px;
  right: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 7px solid #95ec69;
  content: "";
}

.bubble .image-tag {
  margin-top: 6px;
  color: #888888;
  font-size: 10px;
  opacity: 1;
}

.typing {
  background: #ffffff;
}

.composer-area {
  border-top-color: #d7d7d7;
  background: rgba(247, 247, 247, 0.98);
  padding: 8px 10px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(14px);
}

.composer {
  gap: 5px;
  min-width: 0;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #ffffff;
  padding: 6px;
}

.composer textarea {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 36px;
  padding: 7px 3px 6px;
  color: #111111;
  font-size: 16px;
}

.attach-button {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  color: #555555;
}

.attach-button:hover {
  background: #f2f2f2;
}

.send-button {
  width: auto;
  min-width: 56px;
  height: 36px;
  border-radius: 4px;
  background: #07c160;
  padding: 0 13px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.send-button:disabled {
  background: #b8e6ca;
  opacity: 1;
}

.image-preview {
  margin-left: 43px;
}

.image-preview img {
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.safety-note {
  color: #aaaaaa;
}

.toast {
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
}

@media (min-width: 821px) {
  .chat-shell {
    margin: 20px auto;
    height: calc(100dvh - 40px);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 5px 28px rgba(0, 0, 0, 0.16);
  }

  .topbar {
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 420px) {
  .messages {
    padding-inline: 10px;
  }

  .bubble {
    max-width: calc(100% - 76px);
  }
}
