:root {
  --wx-green: #07c160;
  --wx-green-dark: #06ad56;
  --wx-bg: #ededed;
  --wx-bar: #ededed;
  --wx-bubble-me: #95ec69;
  --wx-bubble-them: #ffffff;
  --ink: #111;
  --muted: #888;
  --line: rgba(0, 0, 0, 0.08);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--wx-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  background: var(--wx-bg);
}

.top {
  flex-shrink: 0;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: var(--wx-bar);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.status {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.thread {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--wx-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.thread.has-bg {
  background-color: transparent;
}

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

.row.me {
  flex-direction: row-reverse;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(70%, 320px);
  min-width: 0;
}

.row.me .col {
  align-items: flex-end;
}

.row.them .col {
  align-items: flex-start;
}

.msg-time {
  font-size: 11px;
  color: #b2b2b2;
  line-height: 1.2;
  padding: 0 2px;
}

.read-state {
  color: #b2b2b2;
}

.read-state.is-read {
  color: #b2b2b2;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: #cfcfcf;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.5px;
  overflow: hidden;
}

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

.row.me .avatar {
  background: #07c160;
}

.row.them .avatar {
  background: #fff;
}

.bubble {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.45;
  font-size: 16px;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.row.them .bubble {
  background: var(--wx-bubble-them);
}

.row.me .bubble {
  background: var(--wx-bubble-me);
}

.bubble.media {
  padding: 4px;
  background: transparent !important;
  box-shadow: none;
}

.bubble img.msg-img {
  display: block;
  max-width: min(220px, 58vw);
  max-height: 280px;
  border-radius: 6px;
  cursor: pointer;
}

.bubble video.msg-video {
  display: block;
  max-width: min(240px, 62vw);
  max-height: 280px;
  border-radius: 6px;
  background: #000;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 240px;
  padding: 10px 12px;
  background: #fff;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}

.row.me .file-card {
  background: var(--wx-bubble-me);
}

.file-ico {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #576b95;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.file-meta {
  min-width: 0;
}

.file-meta .name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta .size {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.time {
  align-self: center;
  font-size: 12px;
  color: #b2b2b2;
  margin: 4px 0;
}

.composer {
  flex-shrink: 0;
  padding: 8px 8px calc(8px + var(--safe-b) + var(--kb));
  background: #f7f7f7;
  border-top: 1px solid var(--line);
}

.composer form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 0;
  outline: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  font: inherit;
  font-size: 16px;
}

.composer #send {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--wx-green);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.composer #send:disabled {
  opacity: 0.4;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 20px;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.uploading {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
}

.recall-tip {
  text-align: center;
  width: 100%;
}

.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
}

.action-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.action-panel {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-b));
  display: grid;
  gap: 8px;
}

.action-panel button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 17px;
  background: #fff;
  cursor: pointer;
}

.action-recall {
  color: #fa5151;
  font-weight: 600;
}

.action-cancel {
  color: #111;
}
