:root {
  --paper: #f7f2ea;
  --surface: #fffdf8;
  --surface-soft: #fbf5ec;
  --ink: #231b18;
  --muted: #756a60;
  --line: #e4d7c6;
  --green: #1f7a64;
  --green-dark: #155242;
  --green-soft: #e9f5ef;
  --red: #b93832;
  --red-soft: #fff0ee;
  --gold: #c9a35c;
  --plum: #6d5aa6;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 122, 100, .06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 122, 100, .05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wechat-shell {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0;
  background: #f2f4f6;
}

.wechat-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  height: 72px;
  border-bottom: 1px solid #e7e7e7;
  background: rgba(249, 249, 249, .96);
  backdrop-filter: blur(12px);
}

.top-title {
  text-align: center;
  line-height: 1.2;
}

.top-title strong,
.top-title span {
  display: block;
}

.top-title strong {
  font-size: 19px;
  letter-spacing: 0;
}

.top-title span {
  margin-top: 4px;
  color: #767676;
  font-size: 13px;
}

.top-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto;
  color: #252525;
  background: transparent;
  font-size: 30px;
  line-height: 1;
}

.screen {
  display: none;
  min-height: calc(100vh - 72px);
  padding: 28px 22px 104px;
}

.screen.is-active {
  display: block;
}

.screen-welcome {
  background:
    linear-gradient(180deg, #f7faf8 0%, #f0f3f5 48%, #f7f2ea 100%);
}

.welcome-center {
  display: grid;
  justify-items: center;
  min-height: calc(100vh - 176px);
  align-content: center;
  text-align: center;
}

.app-icon {
  width: 116px;
  height: 116px;
  border: 1px solid rgba(185, 56, 50, .18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(96, 72, 44, .16);
}

.overline {
  margin: 24px 0 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.12;
}

h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.24;
}

.welcome-copy {
  max-width: 308px;
  margin: 18px 0 34px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 320px);
  min-height: 52px;
  padding: 13px 18px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(31, 122, 100, .22);
}

.screen-home,
.screen-me {
  background:
    linear-gradient(90deg, rgba(31, 122, 100, .06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31, 122, 100, .05) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px, 28px 28px, auto;
}

.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 116px;
  margin: -28px -22px 26px;
  padding: 22px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(185, 56, 50, .96), rgba(31, 122, 100, .96)),
    #8b4b43;
}

.home-hero .overline {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, .82);
}

.home-hero h2 {
  max-width: 240px;
}

.home-hero img {
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, .55);
  border-radius: 8px;
  background: #fff;
}

.create-card,
.companion-card,
.profile-panel {
  width: 100%;
  border: 1px solid rgba(228, 215, 198, .9);
  border-radius: 8px;
  background: rgba(255, 253, 248, .97);
  box-shadow: 0 18px 38px rgba(73, 53, 33, .12);
}

.create-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 178px;
  padding: 28px 22px;
  color: var(--ink);
  text-align: center;
}

.create-symbol {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  color: #fff;
  background:
    linear-gradient(135deg, var(--red), var(--green));
  font-size: 38px;
  line-height: 1;
}

.create-card strong {
  font-size: 26px;
  line-height: 1.2;
}

.create-card em {
  max-width: 282px;
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
  line-height: 1.6;
}

.companion-card {
  margin-top: 20px;
  padding: 18px;
}

.companion-main {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 14px;
  align-items: center;
}

.companion-main img {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(185, 56, 50, .18);
  border-radius: 8px;
  background: #fff;
}

.companion-main strong,
.companion-main span {
  display: block;
}

.companion-main strong {
  font-size: 23px;
}

.companion-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.small-pill,
.green-pill,
.outline-pill,
.purple-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.small-pill {
  min-height: 38px;
  color: #4f4841;
  background: #eee9e2;
}

.companion-actions,
.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.green-pill {
  color: #fff;
  background: var(--green);
}

.outline-pill {
  color: var(--green-dark);
  border: 1px solid #9acbbb;
  background: #fffdf8;
}

.purple-pill {
  color: #fff;
  background: var(--plum);
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: 92px;
  color: #9b9288;
  text-align: center;
}

.empty-state img {
  width: 82px;
  height: 82px;
  opacity: .58;
}

.profile-panel {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 16px;
  align-items: center;
  padding: 20px;
}

.profile-panel img {
  width: 64px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.profile-panel .overline {
  margin: 0 0 8px;
}

.profile-panel p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  right: auto;
  z-index: 35;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 430px;
  height: 82px;
  margin: 0;
  border-top: 1px solid #e1ded9;
  background: rgba(255, 253, 248, .97);
  backdrop-filter: blur(12px);
}

.tabbar[hidden] {
  display: none;
}

.tab-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: #8a837b;
  background: transparent;
}

.tab-item span {
  font-size: 25px;
  line-height: 1;
}

.tab-item strong {
  font-size: 14px;
}

.tab-item.is-active {
  color: var(--green);
}

.sheet-backdrop,
.chat-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: end;
  justify-items: center;
  background: rgba(22, 18, 16, .48);
}

.sheet-backdrop[hidden],
.chat-panel[hidden] {
  display: none;
}

.sheet {
  width: min(100vw, 430px);
  padding: 12px 22px 26px;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 -22px 45px rgba(34, 24, 18, .22);
}

.sheet-handle {
  width: 44px;
  height: 4px;
  margin: 0 auto 22px;
  border-radius: 999px;
  background: #d7cec3;
}

.sheet h2 {
  font-size: 24px;
}

.sheet p {
  margin: 14px 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.72;
}

.link-sheet .sheet-actions {
  grid-template-columns: 1fr 1fr;
}

.share-url {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-soft);
}

.chat-panel {
  align-items: stretch;
  background: rgba(0, 0, 0, .28);
}

.chat-window {
  display: grid;
  grid-template-rows: 62px 1fr 70px;
  width: min(100vw, 430px);
  min-height: 100vh;
  background: #efebe4;
}

.chat-window header {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  border-bottom: 1px solid #ddd4ca;
  background: #fbf8f4;
  text-align: center;
}

.chat-window header .top-icon {
  grid-row: 1 / 3;
}

.chat-window header strong {
  grid-column: 2;
  grid-row: 1;
  align-self: end;
}

.chat-window header span {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 16px;
}

.bubble {
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.bubble.bot {
  align-self: flex-start;
  color: var(--ink);
  background: #fffdf8;
}

.bubble.user {
  align-self: flex-end;
  color: #fff;
  background: var(--green);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 74px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid #ddd4ca;
  background: #fbf8f4;
}

.chat-form input {
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chat-form button {
  min-height: 44px;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

@media (min-width: 700px) {
  body {
    padding: 16px 0;
  }

  .wechat-shell {
    min-height: calc(100vh - 32px);
    margin: 0 auto;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(42, 33, 24, .18);
  }

  .tabbar {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .chat-window {
    min-height: calc(100vh - 32px);
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
  }
}
