:root {
  --bg: #ededed;
  --panel: #ffffff;
  --nav: #ededed;
  --line: #e6e6e6;
  --text: #191919;
  --muted: #9b9b9b;
  --green: #07c160;
  --green-dark: #06a552;
  --bubble: #95ec69;
  --red: #fa5151;
  --link: #576b95;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background: #c9cdd2;
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
}

/* ---- 手机外框 ---- */
.app {
  width: 100%;
  max-width: 460px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

@media (min-width: 600px) {
  body {
    padding: 24px 0;
    align-items: center;
  }

  .app {
    height: min(900px, calc(100dvh - 48px));
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  }
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- 顶部导航 ---- */
.navbar {
  flex: 0 0 auto;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0) 44px 0;
  background: var(--nav);
  border-bottom: 1px solid #dcdcdc;
  position: relative;
}

.nav-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-back {
  position: absolute;
  left: 2px;
  top: env(safe-area-inset-top, 0);
  height: 46px;
  padding: 0 12px;
  border: none;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}

.nav-right {
  position: absolute;
  right: 4px;
  top: env(safe-area-inset-top, 0);
  height: 46px;
  display: flex;
  align-items: center;
}

.nav-plus {
  border: none;
  background: none;
  padding: 0 10px;
  font-size: 22px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}

/* ---- 内容区 ---- */
.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 22px;
}

.group {
  background: var(--panel);
  margin-top: 10px;
}

.group:first-child {
  margin-top: 0;
}

.group-title {
  padding: 18px 14px 6px;
  font-size: 13px;
  color: var(--muted);
}

.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--panel);
  position: relative;
  cursor: pointer;
}

.cell + .cell::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--line);
}

.cell-static {
  cursor: default;
}

.cell-main {
  flex: 1;
  min-width: 0;
}

.cell-title {
  font-size: 16px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-desc {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chev {
  color: #c8c8c8;
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}

/* ---- 头像 ---- */
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 15px;
  overflow: hidden;
}

.avatar-lg {
  width: 60px;
  height: 60px;
  flex-basis: 60px;
  border-radius: 8px;
  font-size: 19px;
}

.avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

/* ---- 角标 ---- */
.dot-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--red);
  color: #ffffff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.num-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #ffffff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 16px;
  border-radius: 3px;
  background: #f0f0f0;
  color: var(--muted);
  vertical-align: 1px;
}

/* ---- 会话列表 ---- */
.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-name {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-preview {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-side {
  align-self: flex-start;
  padding-top: 4px;
  flex: 0 0 auto;
}

.chat-time {
  font-size: 12px;
  color: #b2b2b2;
  font-variant-numeric: tabular-nums;
}

/* ---- 我 ---- */
.me-card {
  padding: 18px 14px;
  gap: 14px;
}

.me-name {
  font-size: 19px;
  font-weight: 600;
}

.cell-btn {
  width: 100%;
  border: none;
  font: inherit;
  color: var(--text);
  text-align: left;
}

.cell-btn.danger {
  justify-content: center;
  padding: 14px;
  color: var(--red);
  font-size: 16px;
}

/* ---- 底部 Tab ---- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  background: #f7f7f7;
  border-top: 1px solid #dcdcdc;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0 5px;
  border: none;
  background: none;
  color: #7a7e83;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

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

.tab-ico {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
}

.tab-ico svg {
  display: block;
  width: 26px;
  height: 26px;
}

/* ---- 右上角弹出菜单 ---- */
.quick-menu {
  position: absolute;
  top: 50px;
  right: 10px;
  z-index: 20;
  min-width: 156px;
  background: #4c4c4c;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.quick-menu[hidden] {
  display: none;
}

.quick-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: #ffffff;
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.quick-menu button + button {
  border-top: 1px solid #5f5f5f;
}

/* ---- 按钮 ---- */
.btn-primary,
button.primary {
  display: block;
  width: 100%;
  padding: 11px 16px;
  font: inherit;
  font-size: 16px;
  color: #ffffff;
  background: var(--green);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-primary:disabled,
button.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost {
  display: block;
  width: 100%;
  padding: 11px 16px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-mini {
  flex: 0 0 auto;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--link);
  background: #f2f2f2;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.btn-mini.primary {
  background: var(--green);
  color: #ffffff;
}

.btn-mini:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-btn {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 10px;
  border: none;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.pad {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 0;
}

/* ---- 表单 ---- */
.form {
  display: flex;
  flex-direction: column;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 10px 0;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.field input:focus {
  outline: none;
  border-bottom-color: var(--green);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  position: relative;
}

.form-row + .form-row::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--line);
}

.form-label {
  flex: 0 0 76px;
  font-size: 15px;
}

.form-input {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  font: inherit;
  font-size: 15px;
  text-align: right;
  color: var(--text);
  background: transparent;
  border: none;
}

.form-input:focus {
  outline: none;
}

.form-input::placeholder {
  color: #b9b9b9;
}

.form-value {
  flex: 1;
  text-align: right;
  font-size: 15px;
  color: var(--muted);
}

/* ---- 提示 ---- */
.alert {
  margin: 10px 14px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.55;
  border-radius: 6px;
  background: #fdecec;
  color: #c02b2b;
  word-break: break-word;
}

.alert.ok {
  background: #e8f7ee;
  color: #1f7a45;
}

.alert[hidden] {
  display: none;
}

.blank {
  padding: 26px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.blank-foot {
  padding: 18px 16px;
  text-align: center;
  font-size: 12px;
  color: #b2b2b2;
  line-height: 1.65;
}

/* ---- 邀请码 ---- */
.invite-box {
  padding: 24px 16px;
  text-align: center;
}

.invite-code {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 3px;
  margin-bottom: 8px;
  word-break: break-all;
}

/* ---- 归档 ---- */
.archive-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.archive-img {
  display: block;
  max-width: 200px;
  margin-top: 6px;
  border-radius: 4px;
}

/* ---- 聊天页 ---- */
.chat-screen {
  background: var(--bg);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px max(12px, env(safe-area-inset-right)) 18px
    max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.time-sep {
  text-align: center;
  font-size: 12px;
  color: #a6a6a6;
}

.msg {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.msg.mine {
  flex-direction: row-reverse;
}

.msg .avatar {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 4px;
  font-size: 14px;
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: calc(100% - 100px);
}

.msg.mine .msg-body {
  align-items: flex-end;
}

.bubble {
  position: relative;
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: #ffffff;
  border-radius: 5px;
  word-break: break-word;
  white-space: pre-wrap;
}

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

.msg.mine .bubble {
  background: var(--bubble);
}

.msg.mine .bubble::before {
  left: auto;
  right: -5px;
  border-width: 5px 0 5px 6px;
  border-color: transparent transparent transparent var(--bubble);
}

.msg-state {
  font-size: 11px;
  color: var(--muted);
}

/* ---- 图片 / 文件消息 ---- */
.img-bubble {
  padding: 2px;
}

.img-bubble::before {
  display: none;
}

.img-trigger {
  display: block;
  padding: 16px 20px;
  font: inherit;
  font-size: 13px;
  color: var(--link);
  background: none;
  border: none;
  cursor: pointer;
}

.img-bubble[data-state="loading"] .img-trigger {
  color: var(--muted);
  cursor: default;
}

.att-img {
  display: block;
  max-width: 210px;
  max-height: 300px;
  border-radius: 4px;
}

.burn-timer {
  font-size: 11px;
  color: #b4544a;
  padding: 4px 2px 2px;
}

.destroyed {
  display: block;
  padding: 14px 16px;
  font-size: 12px;
  color: var(--muted);
}

.file-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-bubble::before {
  display: none;
}

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

.file-size {
  font-size: 11px;
  color: var(--muted);
}

/* ---- 输入栏 ---- */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: #f7f7f7;
  border-top: 1px solid #dcdcdc;
}

.icon-plus {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  margin-bottom: 2px;
  border: 2px solid #7a7e83;
  border-radius: 50%;
  background: none;
  color: #7a7e83;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.composer textarea {
  flex: 1;
  min-height: 36px;
  max-height: 110px;
  padding: 8px 10px;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: #ffffff;
  border: none;
  border-radius: 5px;
  resize: none;
}

.composer textarea:focus {
  outline: none;
}

.send-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  color: #ffffff;
  background: var(--green);
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.send-btn:disabled {
  background: #d9d9d9;
  color: #f2f2f2;
  cursor: default;
}

/* ---- 登录 / 注册 ---- */
.auth-app {
  background: #ffffff;
}

.auth-screen {
  overflow-y: auto;
  padding: 0 26px 32px;
}

.brand {
  padding: 56px 0 26px;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: transparent;
  border: none;
  padding: 0;
}

.card.form {
  gap: 0;
}

.hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

/* ---- 撤回 ---- */
.sys-msg {
  align-self: center;
  padding: 3px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #8b8b8b;
  background: #dcdcdc;
  border-radius: 4px;
  text-align: center;
}

.msg-state.read {
  color: #5f9c74;
}

.action-mask {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.35);
}

.action-sheet {
  width: 100%;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: #f7f7f7;
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-item {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.action-item.danger {
  color: var(--red);
}

/* ---- 窄屏手机（≤360px） ---- */
@media (max-width: 360px) {
  body {
    font-size: 14px;
  }

  .navbar {
    padding-left: 38px;
    padding-right: 38px;
  }

  .nav-title {
    font-size: 15px;
  }

  .cell {
    gap: 10px;
    padding: 10px 12px;
  }

  .chat-name,
  .cell-title {
    font-size: 15px;
  }

  .avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 14px;
  }

  .avatar-lg {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
  }

  .msg .avatar {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .msg-body {
    max-width: calc(100% - 86px);
  }

  .bubble {
    padding: 8px 10px;
    font-size: 14px;
  }

  .att-img {
    max-width: 168px;
    max-height: 240px;
  }

  .composer {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .composer textarea {
    font-size: 14px;
  }

  .send-btn {
    padding: 8px 11px;
  }

  .form-label {
    flex-basis: 66px;
  }
}

/* ---- 横屏 / 矮屏 ---- */
@media (orientation: landscape) and (max-height: 520px) {
  .navbar {
    min-height: 40px;
  }

  .nav-back,
  .nav-right {
    height: 40px;
  }

  .messages {
    gap: 10px;
    padding-top: 8px;
  }

  .composer {
    padding-top: 5px;
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0));
  }

  .brand {
    padding: 22px 0 12px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .action-sheet {
    max-height: 88dvh;
    overflow-y: auto;
  }
}
