/* chat3 手机优先样式：竖屏、最大宽度 480px、触控目标 >= 44px、不横向滚动 */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #17181a;
  --muted: #8b9099;
  --line: #e8eaee;
  --accent: #2f6fed;
  --accent-dark: #2358c4;
  --danger: #e5484d;
  --radius: 14px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  padding: 0 14px;
}

button:active {
  opacity: 0.82;
}

input,
select {
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}

.btn-sm {
  min-height: 44px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.btn-sm.danger {
  color: var(--danger);
  border-color: #f3c9cb;
}

/* ---------------- 登录页 ---------------- */

.login-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #eef0f4;
  padding: 24px;
}

.qr-box {
  width: 240px;
  height: 240px;
  padding: 14px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 34px rgba(18, 26, 45, 0.12);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.qr-box svg {
  display: block;
  width: 100%;
  height: 100%;
}

.login-tip {
  margin: 18px 0 0;
  font-size: 13px;
  color: #7b828d;
  letter-spacing: 0.5px;
}

.login-brand {
  margin: 0 0 22px;
  font-size: 15px;
  font-weight: 600;
  color: #3b414b;
  letter-spacing: 2px;
}

.pw-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 20, 30, 0.45);
}

.pw-panel {
  width: 100%;
  max-width: 320px;
  padding: 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.pw-panel h1 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
}

.pw-panel input {
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  outline: none;
}

.pw-panel input:focus {
  border-color: var(--accent);
  background: #fff;
}

.pw-error {
  min-height: 20px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.pw-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.pw-actions button {
  flex: 1;
}

.shake {
  animation: shake 0.32s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

/* ---------------- 聊天页 ---------------- */

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  overflow: hidden;
}

.chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.chat-top .peer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
}

.chat-top .peer span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9ced6;
  flex: 0 0 auto;
}

.dot.online {
  background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, 0.15);
}

.msg-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty {
  margin: auto;
  font-size: 13px;
  color: var(--muted);
}

.time-sep {
  align-self: center;
  margin: 4px 0;
  font-size: 11px;
  color: var(--muted);
}

.bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.self {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bubble.peer {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble.pending {
  opacity: 0.7;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--bg);
  outline: none;
}

.composer input:focus {
  border-color: var(--accent);
  background: #fff;
}

.composer button {
  flex: 0 0 auto;
  padding: 0 18px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------------- 确认弹层 ---------------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 20, 30, 0.45);
}

.dialog {
  width: 100%;
  max-width: 320px;
  padding: 20px;
  background: #fff;
  border-radius: 16px;
}

.dialog p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.6;
}

.dialog .actions {
  display: flex;
  gap: 10px;
}

.dialog .actions button {
  flex: 1;
}

/* ---------------- 管理页 ---------------- */

.admin-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  overflow: hidden;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}

.admin-head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.tabs button {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
}

.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.panel {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  background: var(--bg);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.filters select,
.filters input {
  flex: 1 1 130px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #4a505a;
  min-height: 44px;
}

.filters label input {
  min-height: 0;
  width: 18px;
  height: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: #4a505a;
}

.row-head .who {
  font-weight: 600;
  color: var(--text);
}

.row-head .time {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.row-body {
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.row-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11px;
  background: #eef0f4;
  color: #6b7280;
}

.tag.hidden {
  background: #f3eef0;
  color: #9a6b73;
}

.tag.recall {
  background: #f1efe6;
  color: #8a7a45;
}

.tag.ok {
  background: #e8f5ee;
  color: #237a4b;
}

.check {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.panel .empty {
  padding: 30px 0;
  text-align: center;
}

.form-box {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
}

.form-box input {
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  margin-bottom: 8px;
  outline: none;
}

.form-box .toolbar {
  margin-bottom: 0;
}

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