/* 微信会话页风格 */
* { box-sizing: border-box; }

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

body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  color: #111;
  background: #111;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background: #1a1a1a;
}

.screen {
  width: min(480px, 100%);
  background: #ededed;
  position: relative;
}

/* —— 登录 —— */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #ededed;
}

.login-card {
  width: 100%;
  max-width: 300px;
  text-align: center;
}

.login-ava {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  margin: 0 auto 14px;
  background: #ccc;
}

.login h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.login-tip {
  margin: 8px 0 28px;
  color: #888;
  font-size: 14px;
}

.login input {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 12px 14px;
  background: #fff;
  margin-bottom: 16px;
  outline: 0;
  user-select: text;
}

.login input:focus {
  box-shadow: 0 0 0 1px #07c160 inset;
}

.wx-btn {
  width: 100%;
  border: 0;
  border-radius: 4px;
  padding: 11px 16px;
  background: #07c160;
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.wx-btn:active {
  background: #06ad56;
}

.error {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: #fa5151;
  font-size: 13px;
}

/* —— 导航栏 —— */
.chat {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.wx-nav {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: 48px;
  padding: env(safe-area-inset-top, 0) 4px 0;
  background: #ededed;
  border-bottom: 0.5px solid #d0d0d0;
  flex-shrink: 0;
}

.nav-back {
  border: 0;
  background: none;
  font-size: 32px;
  line-height: 1;
  color: #111;
  cursor: pointer;
  padding: 0 0 4px;
  height: 44px;
}

.nav-title {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-more {
  text-align: center;
  font-size: 18px;
  letter-spacing: 1px;
  color: #111;
  font-weight: 700;
}

/* —— 消息区 —— */
.wx-messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 16px;
  background: #ededed;
  -webkit-overflow-scrolling: touch;
}

.msg {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  max-width: 100%;
}

.msg.them {
  justify-content: flex-start;
  padding-right: 48px;
}

.msg.me {
  justify-content: flex-end;
  padding-left: 48px;
  flex-direction: row;
}

.ava {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: #c8c8c8;
  display: block;
}

.msg.them .ava {
  margin-right: 8px;
}

.msg.me .ava {
  margin-left: 8px;
  order: 2;
}

/* 自己头像：简单色块 */
.ava.self {
  display: grid;
  place-items: center;
  background: #576b95;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.bubble {
  position: relative;
  max-width: calc(100% - 48px);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  user-select: text;
}

/* 对方白气泡 */
.msg.them .bubble {
  background: #fff;
  color: #111;
}

.msg.them .bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 6px 5px 0;
  border-color: transparent #fff transparent transparent;
}

/* 自己绿气泡（微信经典） */
.msg.me .bubble {
  background: #95ec69;
  color: #111;
  order: 1;
}

.msg.me .bubble::before {
  content: "";
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 6px;
  border-color: transparent transparent transparent #95ec69;
}

.msg.err .bubble {
  background: #fff;
  color: #fa5151;
}

.msg.err .bubble::before {
  border-color: transparent #fff transparent transparent;
}

/* —— 底栏 —— */
.wx-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: #f7f7f7;
  border-top: 0.5px solid #d0d0d0;
}

.wx-inputbar textarea {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  resize: none;
  outline: 0;
  line-height: 1.35;
  user-select: text;
}

.send-btn {
  flex-shrink: 0;
  height: 36px;
  min-width: 60px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: #07c160;
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.send-btn:disabled {
  background: #ddd;
  color: #999;
  cursor: default;
}

.send-btn:not(:disabled):active {
  background: #06ad56;
}

[hidden] { display: none !important; }

@media (min-width: 481px) {
  .screen {
    box-shadow: 0 0 0 1px #000, 0 12px 40px rgba(0, 0, 0, 0.45);
    min-height: min(860px, 100dvh);
    height: min(860px, 100dvh);
    margin: 16px 0;
    border-radius: 0;
  }
  .login {
    min-height: min(860px, 100dvh);
  }
  .chat {
    height: 100%;
  }
}
