/* LKChat — 纸与墨 */
:root {
  --paper: #f4efe4;
  --paper-2: #efe7d8;
  --card: #fffcf6;
  --ink: #2d2924;
  --ink-soft: #574f45;
  --muted: #948a7c;
  --line: #e6dccb;
  --line-strong: #d8cab2;
  --accent: #b3543d;
  --accent-dark: #8f3f2c;
  --accent-soft: #f6e7dd;
  --ok: #4d7c5f;
  --shadow: 0 14px 34px -20px rgba(62, 47, 31, .45);
  --radius: 18px;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, #fffaf0 0%, rgba(255, 250, 240, 0) 60%),
    radial-gradient(900px 500px at 110% 10%, #f7e9dc 0%, rgba(247, 233, 220, 0) 55%);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(244, 239, 228, .82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto; padding: 10px 22px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  font-family: var(--serif); font-weight: 700; font-size: 22px;
  letter-spacing: .5px; text-decoration: none; color: var(--ink); flex: none;
}
.brand em { font-style: normal; color: var(--accent); }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 12px; border-radius: 999px; font-size: 14px;
  color: var(--ink-soft); text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(179, 84, 61, .08); }
.nav a.active { background: var(--ink); color: #fffaf2; }
.user-chip {
  display: inline-flex; align-items: center; justify-content: center;
  flex: none; text-decoration: none; border-radius: 50%; outline: none;
}
.user-chip .avatar {
  width: 34px; height: 34px; font-size: 15px;
  background: var(--accent);
  color: #fffaf2;
  box-shadow: 0 3px 10px -2px rgba(143, 63, 44, .45);
  transition: background .15s ease, box-shadow .15s ease, transform .12s ease;
}
.user-chip:hover .avatar {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px rgba(143, 63, 44, .55);
}
.user-chip:active .avatar { transform: translateY(0); }
.user-chip:focus-visible .avatar { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 5px var(--accent); }

/* ---------- 页面容器 ---------- */
.page { max-width: 980px; margin: 0 auto; padding: 26px 22px 90px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-family: var(--serif); font-size: 27px; margin: 0; letter-spacing: .5px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fffaf2;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  transition: background .15s, transform .05s, box-shadow .15s;
  font-family: var(--sans);
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn.ghost:hover { background: rgba(45, 41, 36, .04); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { background: transparent; border-color: #e2c3bb; color: #a5452f; }
.btn.danger:hover { background: #fbeee9; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; letter-spacing: .3px; }
.input, .textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: #fffdf9;
  font-size: 15px; color: var(--ink); font-family: var(--sans);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { font-family: var(--serif); font-size: 16px; line-height: 1.9; resize: vertical; min-height: 220px; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-error {
  background: #fbeee9; border: 1px solid #eccfc6; color: #8e3a26;
  padding: 9px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 4px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; color: var(--ink-soft); }
.switch input { appearance: none; width: 40px; height: 23px; border-radius: 999px; background: #ded4c2; position: relative; cursor: pointer; transition: background .18s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(17px); }

/* ---------- 登录 / 注册 ---------- */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card {
  width: 100%; max-width: 392px; background: var(--card);
  border: 1px solid var(--line); border-radius: 26px; padding: 38px 32px 30px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), #d98f73 60%, #e8c9a8);
}
.auth-brand { font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: .5px; line-height: 1.1; }
.auth-brand em { font-style: normal; color: var(--accent); }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 8px 0 26px; }
.auth-foot { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-foot a { color: var(--accent); text-decoration: none; }
.auth-note { margin-top: 18px; font-size: 11.5px; color: #a79c8c; line-height: 1.7; text-align: center; }

/* ---------- 信件列表 ---------- */
.letters { display: flex; flex-direction: column; gap: 10px; }
.letter-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 15px 18px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  text-decoration: none; color: inherit;
  transition: border-color .15s, transform .12s, box-shadow .15s;
  position: relative;
}
.letter-item:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.letter-item.unread { border-left: 3px solid var(--accent); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--accent); color: #fffaf2;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 18px; user-select: none;
  box-shadow: 0 2px 7px -3px rgba(143, 63, 44, .45);
}
.avatar.anon { background: #8d8375; color: #fffaf2; box-shadow: none; }
.letter-main { flex: 1; min-width: 0; }
.letter-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.peer { font-size: 14.5px; font-weight: 600; }
.letter-line time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.letter-title { font-family: var(--serif); font-size: 17px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.letter-preview { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block; font-size: 11px; color: var(--accent-dark);
  background: var(--accent-soft); padding: 1px 8px; border-radius: 999px;
  vertical-align: middle; margin-left: 6px; font-family: var(--sans);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 8px; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; padding: 70px 20px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255, 252, 246, .5);
}
.empty .empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .7; }
.empty h3 { font-family: var(--serif); color: var(--ink-soft); font-weight: 500; margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* ---------- 信件详情 ---------- */
.paper {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 38px 42px 44px; box-shadow: var(--shadow); position: relative;
}
.paper::after {
  content: ""; position: absolute; left: 42px; right: 42px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(179, 84, 61, .35), transparent);
}
.paper-head { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 24px; }
.paper-head h1 { font-family: var(--serif); font-size: 27px; margin: 0 0 10px; letter-spacing: .5px; }
.paper-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); }
.paper-body { font-family: var(--serif); font-size: 16.5px; line-height: 2.05; white-space: pre-wrap; word-break: break-word; color: #35302a; }
.paper-actions { margin-top: 34px; display: flex; gap: 10px; }
.locked-body {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 50px 20px; color: var(--muted); text-align: center;
}
.locked-body .lock-icon { font-size: 30px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { font-family: var(--serif); font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 180px; margin-bottom: 0; }

/* ---------- 好友 ---------- */
.person {
  display: flex; align-items: center; gap: 13px; padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.person:last-child { border-bottom: none; }
.person .who { flex: 1; min-width: 0; }
.person .name { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .handle { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .actions { display: flex; gap: 8px; }
.tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: #eee8dc; color: #7d7364; }
.tag.ok { background: #e3efe6; color: var(--ok); }
.tag.wait { background: #f7ecd9; color: #99722f; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(38, 31, 24, .45);
  display: grid; place-items: center; padding: 20px; z-index: 90;
  backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 380px; background: var(--card); border-radius: 22px;
  padding: 28px 26px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4);
  border: 1px solid var(--line);
}
.modal h3 { font-family: var(--serif); font-size: 21px; margin: 0 0 6px; }
.modal p { color: var(--muted); font-size: 13px; margin: 0 0 18px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(10px);
  background: #2f2a24; color: #fff8ee; padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; z-index: 120;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #8f3f2c; }

/* ---------- 响应式 ---------- */
@media (max-width: 680px) {
  .topbar-inner { padding: 9px 14px; gap: 10px; }
  .brand { font-size: 19px; }
  .nav a { padding: 6px 9px; font-size: 13px; }
  .page { padding: 18px 14px 80px; }
  .page-head h1 { font-size: 23px; }
  .paper { padding: 26px 22px 30px; border-radius: 18px; }
  .paper-head h1 { font-size: 22px; }
  .paper::after { left: 22px; right: 22px; }
  .card { padding: 20px 18px; }
  .auth-card { padding: 30px 22px 24px; border-radius: 22px; }
  .auth-brand { font-size: 29px; }
  .letter-item { padding: 13px 14px; }
  .avatar { width: 38px; height: 38px; font-size: 16px; }
  .letter-title { font-size: 15.5px; }
}

/* ---------- 6 位 ID ---------- */
.id-big {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 36px;
  letter-spacing: 10px;
  text-align: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 18px 8px 18px 18px;
  border-radius: 14px;
  margin: 4px 0 2px;
  user-select: all;
  -webkit-user-select: all;
}
@media (max-width: 680px) {
  .id-big { font-size: 28px; letter-spacing: 7px; }
}
/* 窄屏：压缩顶栏，极窄时导航换到第二行 */
@media (max-width: 420px) {
  .topbar-inner { padding: 9px 12px; gap: 8px; }
  .brand { font-size: 19px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; }
  .user-chip .avatar { width: 42px; height: 42px; font-size: 18px; }
}
@media (max-width: 360px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 2px; }
  .brand { flex: 1 1 auto; }
  .user-chip { order: 2; }
  .user-chip .avatar { width: 48px; height: 48px; font-size: 20px; }
  .nav { order: 3; flex: 1 1 100%; overflow: visible; }
}