:root {
  --brand: #7365f6;
  --brand-2: #4e9dff;
  --ink: #121326;
  --muted: #747894;
  --line: rgba(115, 101, 246, 0.13);
  --panel: rgba(255, 255, 255, 0.82);
  --white: #fff;
  --bubble: #f1f4ff;
  --shadow: 0 24px 70px rgba(42, 39, 120, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --keyboard-inset: 0px;
  --nav-height: 58px;
  --topbar-height: calc(var(--safe-top) + var(--nav-height));
  --assistant-strip-height: 92px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #eef3ff; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overscroll-behavior: none; touch-action: pan-x pan-y; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 9%, rgba(154, 231, 255, 0.54), transparent 25vw),
    radial-gradient(circle at 88% 5%, rgba(115, 101, 246, 0.28), transparent 24vw),
    linear-gradient(145deg, #f8fbff 0%, #eef3ff 46%, #e7e8ff 100%);
}

button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.app-shell {
  width: min(100vw, 520px);
  min-height: 100dvh;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(245,247,255,0.94));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.55), var(--shadow);
}

.page {
  min-height: 100dvh;
  position: relative;
  animation: rise 260ms ease both;
}

@keyframes rise {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Login */
.login-page {
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 24px;
  overflow: hidden;
}
.login-orbit {
  position: absolute;
  inset: -14% -30% auto -30%;
  height: 55%;
  background:
    radial-gradient(circle at 52% 45%, rgba(115,101,246,.18), transparent 18%),
    conic-gradient(from 110deg, rgba(115,101,246,.06), rgba(78,157,255,.22), rgba(154,231,255,.18), rgba(115,101,246,.06));
  filter: blur(.2px);
  border-radius: 0 0 50% 50%;
  pointer-events: none;
}
.login-card {
  align-self: center;
  position: relative;
  padding: 34px 22px 26px;
  border: 1px solid rgba(115,101,246,.14);
  background: rgba(255,255,255,.74);
  backdrop-filter: blur(18px);
  border-radius: 34px;
  box-shadow: 0 22px 80px rgba(56,49,157,.17);
}
.logo-mark {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 28px;
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.08em;
  background: linear-gradient(145deg, var(--brand), #8d7cff 58%, #69cfff);
  box-shadow: 0 18px 40px rgba(115,101,246,.36);
}
.brand-title {
  margin: 0;
  text-align: center;
  font-size: clamp(44px, 13vw, 66px);
  line-height: .88;
  letter-spacing: -0.085em;
  color: #171733;
}
.slogan {
  text-align: center;
  color: var(--brand);
  font-weight: 800;
  margin: 12px 0 0;
  letter-spacing: .04em;
}
.login-copy {
  margin: 22px auto 28px;
  max-width: 300px;
  color: #5f6384;
  text-align: center;
  line-height: 1.8;
  font-size: 14px;
}
.wechat-btn {
  width: 100%;
  border: 0;
  border-radius: 22px;
  min-height: 58px;
  color: #fff;
  background: linear-gradient(135deg, #17c964, #12b957);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(23,201,100,.26);
}
.wechat-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
}
.demo-link {
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(115,101,246,.16);
  min-height: 48px;
  color: var(--brand);
  background: rgba(115,101,246,.08);
  border-radius: 18px;
  font-weight: 800;
}
.login-foot {
  color: #868ca9;
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
  padding-bottom: calc(8px + var(--safe-bottom));
}

/* Shared navigation */
.topbar {
  position: fixed;
  top: var(--safe-top);
  left: 50%;
  right: auto;
  z-index: 1000;
  width: min(100vw, 520px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 92px 1fr 92px;
  align-items: center;
  height: var(--nav-height);
  padding: 0 14px;
  background: rgba(255,255,255,.96);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 1px solid rgba(115,101,246,.08);
}
.nav-center { text-align: center; min-width: 0; }
.nav-title {
  display: block;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.04em;
}
.nav-subtitle {
  display: block;
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  margin-top: -2px;
}
.nav-left, .nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-left { justify-content: flex-start; }
.nav-actions { justify-content: flex-end; }
.nav-text-btn {
  min-width: 54px;
  height: 38px;
  border: 1px solid rgba(115,101,246,.12);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #343650;
  background: rgba(255,255,255,.72);
  box-shadow: 0 8px 22px rgba(50,51,100,.06);
  font-size: 13px;
  font-weight: 900;
}
.nav-text-btn.primary {
  color: var(--brand);
  background: rgba(115,101,246,.1);
}
.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(115,101,246,.12);
  background: rgba(255,255,255,.72);
  color: #343650;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(50,51,100,.06);
}
.icon-btn.primary { background: rgba(115,101,246,.1); color: var(--brand); }
.icon-btn:focus-visible, .nav-text-btn:focus-visible, .guide-entry:focus-visible, .hello-btn:focus-visible, .wechat-btn:focus-visible, .demo-link:focus-visible, .composer-input:focus-visible, .banner:focus-visible {
  outline: 3px solid rgba(115,101,246,.25);
  outline-offset: 2px;
}

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  padding-top: calc(var(--topbar-height) + var(--assistant-strip-height));
}
.assist-strip {
  position: fixed;
  top: var(--topbar-height);
  left: 50%;
  right: auto;
  z-index: 990;
  width: min(100vw, 520px);
  transform: translateX(-50%);
  padding: 12px 16px 6px;
  background: linear-gradient(180deg, rgba(247,249,255,.96), rgba(247,249,255,.76));
}
.banner {
  width: 100%;
  border: 0;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(115,101,246,1), rgba(78,157,255,0.94)),
    radial-gradient(circle at 12% 10%, rgba(255,255,255,.5), transparent 24%);
  box-shadow: 0 18px 40px rgba(115,101,246,.25);
}
.banner-spark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,.18);
  font-size: 22px;
}
.banner-title { display: block; font-weight: 900; font-size: 15px; }
.banner-copy { display: block; opacity: .86; font-size: 12px; margin-top: 2px; }
.banner-chevron { margin-left: auto; opacity: .9; }

.chat-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px calc(168px + var(--keyboard-inset));
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.day-label {
  width: fit-content;
  margin: 10px auto 18px;
  color: #878da8;
  font-size: 12px;
  padding: 7px 12px;
  border: 1px solid rgba(115,101,246,.1);
  border-radius: 999px;
  background: rgba(255,255,255,.7);
}
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 14px 0;
}
.message-row.user { justify-content: flex-end; }
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(145deg, var(--brand), #83c8ff);
  box-shadow: 0 10px 24px rgba(115,101,246,.22);
}
.message-row.user .avatar { order: 2; background: #121326; }
.bubble-wrap { max-width: min(78%, 350px); }
.sender {
  display: block;
  color: #7d829d;
  font-size: 11px;
  margin: 0 0 5px 2px;
}
.message-row.user .sender { text-align: right; margin-right: 2px; }
.bubble {
  border-radius: 22px;
  padding: 13px 15px;
  font-size: 14px;
  line-height: 1.75;
  background: var(--white);
  box-shadow: 0 10px 28px rgba(52,54,80,.07);
  border: 1px solid rgba(115,101,246,.08);
  white-space: pre-wrap;
}
.message-row.ai .bubble { border-top-left-radius: 8px; background: #fff; }
.message-row.user .bubble {
  border-top-right-radius: 8px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand), #5c87ff);
  border: 0;
}
.quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px 6px 46px;
  margin-top: -2px;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid rgba(115,101,246,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  color: #535778;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
}

.online-message {
  align-items: flex-end;
}
.online-bubble-wrap {
  max-width: min(86%, 410px);
}
.online-bubble {
  width: 100%;
  padding: 14px;
  white-space: normal;
  line-height: 1.4;
}
.online-card-title {
  color: #191a33;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.35;
}
.online-card-subtitle {
  margin-top: 4px;
  color: #7d829d;
  font-size: 12px;
  line-height: 1.5;
}
.online-user-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}
.online-user-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(115,101,246,.1);
  border-radius: 16px;
  background: linear-gradient(180deg, #f8faff, #fff);
  box-shadow: 0 8px 20px rgba(52,54,98,.045);
}
.online-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--brand), #7ecaff);
  font-size: 12px;
  font-weight: 900;
}
.online-user-main {
  min-width: 0;
}
.online-user-name {
  overflow: hidden;
  color: #20223e;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.online-user-tags {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  overflow: hidden;
}
.online-user-tags span {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 64px;
  overflow: hidden;
  padding: 3px 6px;
  border-radius: 999px;
  color: #7365f6;
  background: rgba(115,101,246,.08);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hello-btn {
  min-width: 58px;
  min-height: 32px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #4e9dff);
  font-size: 12px;
  font-weight: 900;
}

.typing-dot {
  width: 6px;
  height: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--brand);
  margin-right: 5px;
  animation: blink 1s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; margin-right: 0; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.composer {
  position: fixed;
  left: 50%;
  bottom: var(--keyboard-inset);
  z-index: 1000;
  width: min(100vw, 520px);
  transform: translateX(-50%);
  padding: 12px 14px calc(14px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(247,249,255,0), rgba(247,249,255,.94) 24%, rgba(247,249,255,.98));
}
html.keyboard-open .composer {
  padding-bottom: 12px;
}


.guide-entries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 2px 10px;
}
.guide-entry {
  min-height: 42px;
  border: 1px solid rgba(115,101,246,.12);
  border-radius: 18px;
  color: #343650;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 30px rgba(52,54,98,.11);
  font-size: 14px;
  font-weight: 900;
}
.composer-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  min-height: 62px;
  padding: 8px 9px 8px 16px;
  border-radius: 27px;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(115,101,246,.14);
  box-shadow: 0 18px 52px rgba(52,54,98,.16);
  backdrop-filter: blur(18px);
}
.composer-input {
  border: 0;
  outline: 0;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  line-height: 1.25;
}
.composer-input::placeholder { color: #9aa0bd; }
.round-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 17px;
  display: inline-grid;
  place-items: center;
  color: var(--brand);
  background: rgba(115,101,246,.1);
}
.round-btn.voice { color: #fff; background: linear-gradient(145deg, var(--brand), #75bcff); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(17,19,38,.34);
  backdrop-filter: blur(10px);
  animation: fade 180ms ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(100%, 470px);
  padding: 20px;
  border-radius: 34px;
  background: #fff;
  box-shadow: 0 32px 90px rgba(18,19,38,.28);
  animation: sheet 260ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes sheet { from { transform: translateY(24px); opacity: .3; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal-kicker { color: var(--brand); font-size: 12px; font-weight: 900; letter-spacing: .16em; }
.modal-title { margin: 4px 0 4px; font-size: 28px; letter-spacing: -0.05em; }
.modal-subtitle { max-width: 330px; margin: 0; color: #5f6384; line-height: 1.7; }
.qr-panel {
  margin: 22px 0 18px;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(115,101,246,.1);
  border-radius: 28px;
  background: linear-gradient(180deg, #f8faff, #fff);
}
.qr-code {
  width: 148px;
  height: 148px;
  border-radius: 24px;
  background:
    linear-gradient(90deg, #121326 10px, transparent 10px) 0 0/26px 26px,
    linear-gradient(#121326 10px, transparent 10px) 0 0/26px 26px,
    radial-gradient(circle at 19px 19px, #121326 0 17px, transparent 18px),
    radial-gradient(circle at 129px 19px, #121326 0 17px, transparent 18px),
    radial-gradient(circle at 19px 129px, #121326 0 17px, transparent 18px),
    #fff;
  border: 12px solid #f2f4ff;
  box-shadow: inset 0 0 0 1px rgba(115,101,246,.12), 0 16px 34px rgba(52,54,98,.11);
}
.qr-meta {
  display: grid;
  justify-items: center;
  gap: 8px;
  color: #656a88;
  font-size: 13px;
  line-height: 1.4;
}
.qr-meta-label { color: #8b91aa; font-weight: 800; }
.wx-id {
  display: inline-flex;
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(115,101,246,.1);
  font-weight: 900;
  letter-spacing: .02em;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.copy-btn,
.save-qr-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 18px;
  font-weight: 900;
}
.copy-btn {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), #4e9dff);
  box-shadow: 0 16px 34px rgba(115,101,246,.25);
}
.save-qr-btn {
  border: 1px solid rgba(115,101,246,.14);
  color: var(--brand);
  background: rgba(115,101,246,.08);
}

/* Lists and profile */
.content-page {
  padding-top: var(--topbar-height);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(246,248,255,.96));
}
.page-body { padding: 18px 16px 34px; }
.section-title { margin: 8px 0 14px; font-size: 26px; letter-spacing: -0.055em; }
.chat-list { display: grid; gap: 0; }
.conversation-card {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(18, 19, 38, 0.06);
  background: transparent;
  border-radius: 0;
  padding: 12px 2px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: start;
  text-align: left;
  box-shadow: none;
}
.conversation-card:last-child { border-bottom: 0; }
.conversation-card > span:nth-child(2) { min-width: 0; }
.conv-avatar {
  width: 42px;
  height: 42px;
  grid-row: 1 / span 2;
  margin-top: 1px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, var(--brand), #85ccff);
}
.conv-name {
  margin: 0;
  color: #151626;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}
.conv-msg {
  margin: 6px 0 0;
  color: #9aa0ad;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  align-self: start;
  color: #9aa0ad;
  font-size: 13px;
  line-height: 1.25;
  padding-top: 1px;
}
.profile-hero {
  overflow: hidden;
  border: 1px solid rgba(115,101,246,.12);
  border-radius: 32px;
  padding: 18px;
  background:
    radial-gradient(circle at 85% 10%, rgba(154,231,255,.55), transparent 28%),
    linear-gradient(145deg, rgba(115,101,246,.95), rgba(87,139,255,.95));
  color: #fff;
  box-shadow: 0 18px 48px rgba(115,101,246,.22);
}
.profile-top { display: flex; gap: 14px; align-items: center; }
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.2);
  font-size: 31px;
  font-weight: 900;
}
.profile-name { margin: 0; font-size: 24px; letter-spacing: -0.04em; }
.profile-desc { margin: 5px 0 0; opacity: .85; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.profile-tags span { padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 12px; font-weight: 800; }
.info-grid { display: grid; gap: 12px; margin-top: 16px; }
.info-card {
  padding: 16px;
  border-radius: 24px;
  background: rgba(255,255,255,.8);
  border: 1px solid rgba(115,101,246,.1);
}
.info-label { color: #8b91aa; font-size: 12px; }
.info-value { margin-top: 6px; font-weight: 900; color: #262846; }
.logout-btn {
  width: 100%;
  margin-top: 18px;
  min-height: 52px;
  border: 1px solid rgba(115,101,246,.14);
  border-radius: 18px;
  background: rgba(115,101,246,.08);
  color: var(--brand);
  font-weight: 900;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 140;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 11px 14px;
  border-radius: 999px;
  background: rgba(18,19,38,.9);
  color: #fff;
  font-size: 13px;
  transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.hidden { display: none !important; }

@media (min-width: 760px) {
  body { display: grid; place-items: center; padding: 24px; }
  .app-shell { min-height: min(920px, calc(100vh - 48px)); height: min(920px, calc(100vh - 48px)); max-height: 920px; border-radius: 38px; }
  .page { min-height: min(920px, calc(100vh - 48px)); height: min(920px, calc(100vh - 48px)); }
  .chat-page { height: min(920px, calc(100vh - 48px)); }
  .topbar { top: calc(24px + var(--safe-top)); }
  .assist-strip { top: calc(24px + var(--topbar-height)); }
  .composer { position: fixed; left: 50%; bottom: calc(24px + var(--keyboard-inset)); width: min(100vw, 520px); transform: translateX(-50%); border-radius: 0 0 38px 38px; }
}

@media (max-width: 360px) {
  .online-bubble { padding: 12px; }
  .online-user-card { grid-template-columns: 34px minmax(0, 1fr); }
  .online-user-avatar { width: 34px; height: 34px; }
  .hello-btn { grid-column: 1 / -1; width: 100%; }
  .topbar { grid-template-columns: 68px 1fr 68px; padding-inline: 10px; }
  .nav-text-btn { min-width: 48px; height: 36px; border-radius: 14px; }
  .icon-btn { width: 38px; height: 38px; border-radius: 14px; }
}

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

