:root {
  --bg: #ededed;
  --wx-green: #07c160;
  --wx-nav: #ededed;
  --wx-bubble: #95ec69;
  --wx-text: #111;
  --wx-sub: #888;
  --panel: #fff;
  --line: #e5e5e5;
  --brand: #07c160;
  --danger: #fa5151;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--wx-text);
  background: #f3f3f3;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
  font: inherit;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
  background: #e8e8e8;
  color: #222;
}

.btn:active {
  opacity: 0.85;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: #576b95;
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f0c0c0;
}

/* —— Home —— */
.page-home {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + var(--safe-b));
  background:
    radial-gradient(1200px 600px at 10% -10%, #d8f5e4 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #dff0ff 0%, transparent 50%),
    #f6f7f8;
}

.home-shell {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}

.home-shell h1 {
  margin: 0 0 10px;
  font-size: 24px;
  letter-spacing: 0.02em;
}

.home-lead {
  margin: 0 0 22px;
  color: #666;
  line-height: 1.6;
  font-size: 15px;
}

.home-tip {
  margin: 14px 0 0;
  color: #888;
  font-size: 13px;
}

/* —— Edit —— */
.page-edit {
  min-height: 100dvh;
  padding-bottom: calc(88px + var(--safe-b));
  background: #f2f3f5;
}

.edit-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) 16px 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.edit-top h1 {
  margin: 0;
  font-size: 18px;
}

.edit-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: #888;
}

.edit-main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 14px 12px 24px;
  display: grid;
  gap: 12px;
}

.edit-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.edit-card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field:last-child {
  margin-bottom: 0;
}

.field span {
  font-size: 13px;
  color: #666;
}

.field input,
.msg-editor input,
.msg-editor textarea,
.share-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  background: #fafafa;
}

.msg-editor textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.45;
}

.msg-editor-list {
  display: grid;
  gap: 10px;
}

.msg-editor {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fcfcfc;
}

.msg-editor-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: #888;
}

.msg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.msg-grid .field-full {
  grid-column: 1 / -1;
}

.share-box strong {
  display: block;
  margin-bottom: 8px;
}

.share-row {
  display: flex;
  gap: 8px;
}

.share-row input {
  flex: 1;
  min-width: 0;
}

.edit-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: #999;
  line-height: 1.5;
}

.edit-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + var(--safe-b));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.save-status {
  margin: 0 0 6px;
  min-height: 18px;
  font-size: 12px;
  color: #07c160;
  text-align: center;
}

.save-status.is-err {
  color: var(--danger);
}

@media (max-width: 560px) {
  .msg-grid {
    grid-template-columns: 1fr;
  }
}

.avatar-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.avatar-preview {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  background: #e8e8e8;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #666;
  font-size: 14px;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* —— View: 分享卡片 + PC 聊天记录 —— */
.page-view {
  min-height: 100dvh;
  margin: 0;
  background: #c8c8c8;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
}

.page-view.is-card-mode {
  background: #111;
}

.wx-share-stage {
  width: min(420px, 100%);
  min-height: 100dvh;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--safe-b));
}

.wx-share-chat {
  width: 100%;
  background:
    linear-gradient(180deg, #ebebeb 0%, #e5e5e5 100%);
  border-radius: 16px;
  min-height: min(640px, calc(100dvh - 48px));
  padding: 28px 18px;
  display: flex;
  align-items: flex-end;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.wx-record-card {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 36px;
  border: 0;
  text-align: left;
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wx-record-card:active {
  background: #f7f7f7;
}

.wx-record-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
  margin-bottom: 8px;
  word-break: break-word;
}

.wx-record-card-lines {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.wx-record-card-lines p {
  margin: 0;
  font-size: 13px;
  color: #888;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wx-record-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
  font-size: 12px;
  color: #b2b2b2;
}

.wx-record-card-icon {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background:
    linear-gradient(135deg, #07c160 0 45%, transparent 45%),
    linear-gradient(135deg, transparent 55%, #10aeff 55%);
  background-color: #e8f8ef;
  flex-shrink: 0;
}

.wx-pc {
  width: min(720px, 100%);
  min-height: 100dvh;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.wx-pc-titlebar {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 4px;
  min-height: calc(40px + var(--safe-t));
  padding: var(--safe-t) 4px 0 4px;
  background: #f5f5f5;
  border-bottom: 1px solid #e6e6e6;
  position: sticky;
  top: 0;
  z-index: 3;
  user-select: none;
}

.wx-pc-back {
  border: 0;
  background: transparent;
  width: 44px;
  height: 40px;
  font-size: 28px;
  line-height: 1;
  color: #111;
  cursor: pointer;
  padding: 0;
}

.wx-pc-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 400;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 40px;
  text-align: center;
}

.wx-pc-winbtns {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  height: 40px;
}

.wx-pc-icon {
  border: 0;
  background: transparent;
  width: 46px;
  height: 40px;
  color: #333;
  font-size: 16px;
  line-height: 1;
  cursor: default;
  padding: 0;
}

.wx-pc-icon:hover {
  background: rgba(0, 0, 0, 0.06);
}

.wx-pc-close:hover {
  background: #e81123;
  color: #fff;
}

.wx-pc-min {
  font-size: 12px;
  transform: translateY(-2px);
}

.wx-pc-list {
  flex: 1;
  overflow-y: auto;
  background: #f5f5f5;
  padding: 0 0 calc(20px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}

.wx-pc-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 20px 14px 18px;
  border-bottom: 1px solid #ebebeb;
  align-items: start;
}

.wx-pc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  margin-top: 1px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.wx-pc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.wx-pc-avatar-empty {
  visibility: hidden;
}

.wx-pc-avatar-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.wx-pc-body {
  min-width: 0;
}

.wx-pc-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.wx-pc-name {
  font-size: 12px;
  color: #b1b1b1;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wx-pc-time {
  font-size: 12px;
  color: #b1b1b1;
  flex-shrink: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.wx-pc-text {
  font-size: 14px;
  color: #111;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.wx-num {
  color: inherit;
  font-weight: 700;
  transition: background 0.35s ease, color 0.35s ease;
}

.wx-num.is-flash {
  background: rgba(7, 193, 96, 0.18);
  color: #06ad56;
  border-radius: 3px;
}

.wx-live-dot {
  position: absolute;
  right: 12px;
  bottom: calc(12px + var(--safe-b));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.wx-live-dot.is-on {
  opacity: 1;
}

.wx-live-dot span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #07c160;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(7, 193, 96, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(7, 193, 96, 0);
  }
}

@media (min-width: 760px) {
  .page-view.is-detail-mode {
    padding: 28px 16px;
    align-items: center;
    background: #8f8f8f;
  }

  .page-view.is-card-mode {
    padding: 28px 16px;
    align-items: center;
  }

  .wx-pc {
    width: min(680px, 100%);
    min-height: min(820px, calc(100dvh - 56px));
    height: min(820px, calc(100dvh - 56px));
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 759px) {
  .page-view.is-detail-mode {
    background: #f5f5f5;
  }

  .wx-share-chat {
    border-radius: 0;
    min-height: 100dvh;
    box-shadow: none;
  }

  .wx-share-stage {
    width: 100%;
    padding: 0;
  }

  .wx-pc {
    width: 100%;
    box-shadow: none;
  }

  .wx-pc-row {
    padding: 12px 14px;
  }

  .wx-pc-winbtns .wx-pc-min,
  .wx-pc-winbtns .wx-pc-close {
    display: none;
  }
}
