:root {
  --ink: #1c1917;
  --muted: #78716c;
  --faint: #a8a29e;
  --line: #e7e1d8;
  --paper: #fffcf8;
  --bg: #f3efe8;
  --bg-2: #f7f4ef;
  --accent: #0f6e6b;
  --accent-deep: #0c5c59;
  --accent-soft: #e7f4f2;
  --copper: #c45c26;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 18px 50px rgba(28, 25, 23, .08);
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Songti SC", "Noto Serif CJK SC", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  line-height: 1.4;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  flex: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover { background: #f6f3ee; border-color: #ddd6cc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #14918a 0%, var(--accent) 100%);
  border-color: var(--accent-deep);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 8px 18px rgba(15, 110, 107, .22);
}
.btn-primary:hover { background: linear-gradient(180deg, #0f7f78 0%, var(--accent-deep) 100%); color: #fff; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-sm { padding: 3px 9px; font-size: 12px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }
input[type=text], input[type=password], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, textarea:focus {
  outline: none;
  border-color: #7dccc6;
  box-shadow: 0 0 0 4px rgba(15, 110, 107, .12);
}
textarea:disabled, input:disabled { background: #f6f3ee; color: var(--faint); }
textarea { resize: vertical; }
.form-error { color: var(--danger); min-height: 20px; margin: 6px 0; font-size: 13px; }
.form-ok { color: var(--ok); min-height: 20px; margin: 6px 0; font-size: 13px; }

/* ---------- 居中页面 ---------- */
.auth-page {
  min-height: 100%;
  background:
    radial-gradient(ellipse 70% 48% at 0% -10%, rgba(15, 110, 107, .18), transparent 55%),
    radial-gradient(ellipse 55% 42% at 100% 110%, rgba(196, 92, 38, .16), transparent 50%),
    var(--bg);
}
.center-page { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card, .notice-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 252, 248, .92);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 22px;
  padding: 32px 28px 26px;
  box-shadow: 0 24px 60px rgba(28, 25, 23, .12);
  position: relative;
  overflow: hidden;
}
.login-card::before, .notice-card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #d8a15a 70%, var(--copper));
}
.brand-mark { display: flex; justify-content: center; margin-bottom: 14px; }
.brand-mark img {
  width: 64px; height: 64px; border-radius: 20px;
  box-shadow: 0 10px 24px rgba(15, 110, 107, .28);
}
.login-card h1, .notice-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.02em;
  text-align: center;
}
.login-sub { margin: 8px 0 22px; text-align: center; color: var(--muted); line-height: 1.5; }
.login-card label { display: block; margin-bottom: 14px; color: #44403c; font-size: 13px; font-weight: 600; }
.login-card label input { margin-top: 6px; font-weight: 400; height: 44px; }
.notice-card { text-align: center; }
.notice-text { font-size: 16px; margin: 14px 0 0; color: #44403c; line-height: 1.6; }
.avatar-lg { width: 72px; height: 72px; border-radius: 22px; box-shadow: 0 10px 24px rgba(15, 110, 107, .22); }

/* ---------- 头像 / 消息 ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; background: #e7e1d8; object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; border-radius: 12px; }

.ml-scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.ml-top { text-align: center; padding: 10px 0 2px; }
.ml-top button {
  border: 1px solid var(--line);
  background: rgba(255, 252, 248, .9);
  color: var(--accent);
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
}
.ml-top button:hover { background: #fff; }
.ml-empty { text-align: center; color: var(--faint); padding: 48px 16px; }
.ml-body { padding: 8px 16px 18px; }

.msg { display: flex; gap: 8px; margin: 14px 0; align-items: flex-start; }
.msg-self { flex-direction: row-reverse; }
.msg .avatar { width: 32px; height: 32px; margin-top: 18px; box-shadow: 0 4px 10px rgba(28, 25, 23, .08); }
.msg .wrap { max-width: min(74%, 520px); display: flex; flex-direction: column; min-width: 0; }
.msg-self .wrap { align-items: flex-end; }
.msg .meta { font-size: 12px; color: var(--faint); margin-bottom: 4px; }
.msg .bubble {
  padding: 9px 13px;
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  border: 1px solid rgba(231, 225, 216, .9);
  box-shadow: 0 1px 2px rgba(28, 25, 23, .04);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.msg-self .bubble {
  background: linear-gradient(180deg, #14918a 0%, var(--accent) 100%);
  border-color: transparent;
  color: #fff;
  border-radius: 16px 16px 5px 16px;
  box-shadow: 0 8px 16px rgba(15, 110, 107, .18);
}
.msg-self .bubble a { color: #fff; }
.msg .bubble.bubble-image {
  padding: 4px;
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 6px 16px rgba(28, 25, 23, .06);
}
.msg-self .bubble.bubble-image { border-radius: 16px; }
.msg .bubble img { display: block; max-width: 220px; max-height: 260px; border-radius: 12px; cursor: zoom-in; }
.msg .bubble.bubble-file a { text-decoration: none; display: flex; gap: 8px; align-items: center; }
.msg .bubble.bubble-file .fname { font-weight: 600; }
.msg .bubble.bubble-file .fsize { opacity: .7; font-size: 12px; }
.msg-system { display: block; text-align: center; margin: 14px 0; }
.msg-system .sys-text {
  display: inline-block;
  max-width: 85%;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 252, 248, .85);
  border: 1px solid var(--line);
  color: #57534e;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-system time { display: block; color: var(--faint); font-size: 11px; margin-top: 4px; }

/* ---------- 提示 ---------- */
#toast-box {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  background: rgba(28, 25, 23, .92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  max-width: min(90vw, 420px);
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(28, 25, 23, .22);
}
.toast.toast-error { background: rgba(153, 27, 27, .95); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(28, 25, 23, .46);
  backdrop-filter: blur(3px);
  z-index: 900;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--paper);
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 60px rgba(28, 25, 23, .24);
}
.modal h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.modal p { margin: 0; color: #44403c; line-height: 1.6; }
.modal-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

.lightbox {
  position: fixed; inset: 0; background: rgba(12, 16, 15, .88); z-index: 950;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }

* { scrollbar-width: thin; scrollbar-color: #d6d0c6 transparent; }
