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