/* ===== 基础 ===== */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e8eaed;
  --border-strong: #d8dbe0;
  --text: #1c1f23;
  --text-2: #5c636e;
  --text-3: #939aa5;
  --accent: #2f6df6;
  --accent-soft: #eef3ff;
  --accent-hover: #2359d6;
  --green: #12a065;
  --green-soft: #e9f7f0;
  --amber: #c47b16;
  --amber-soft: #fdf4e4;
  --violet: #7c53d6;
  --violet-soft: #f2edfd;
  --pink: #d64a7c;
  --pink-soft: #fdeef3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 25, 35, .05);
  --shadow: 0 4px 16px rgba(20, 25, 35, .07);
  --shadow-lg: 0 16px 48px rgba(20, 25, 35, .14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ===== 按钮 ===== */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  transition: all .15s;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--text-3); color: var(--text); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger {
  background: var(--surface);
  color: #d33;
  border: 1px solid #f2c9c9;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
}
.btn-danger:hover { background: #fdf2f2; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 6px;
  transition: all .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

.link-btn {
  background: none; border: none;
  color: var(--accent);
  font-size: 13px;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ===== 登录页 ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 480px at 12% -8%, #e9f0ff 0%, transparent 62%),
    radial-gradient(760px 420px at 92% 108%, #f0ecfd 0%, transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: var(--shadow-lg);
}

.auth-brand { text-align: center; margin-bottom: 24px; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4a86ff, #7c53d6);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 12px rgba(74, 134, 255, .3);
}

.auth-brand h1 { font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.auth-sub { color: var(--text-3); font-size: 12.5px; margin-top: 6px; line-height: 1.5; }

.tabs {
  display: flex;
  background: var(--bg);
  border-radius: 9px;
  padding: 3px;
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 7px 4px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: none; flex-direction: column; gap: 14px; }
.auth-form.active { display: flex; }

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}

.auth-form input {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  transition: all .15s;
  font-weight: 400;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.code-row > span:first-child { display: block; }
.code-input { display: flex; gap: 8px; }
.code-input input { flex: 1; min-width: 0; }
.code-input .btn-ghost { font-size: 12.5px; padding: 0 12px; }

.auth-form .btn-primary { padding: 10px; margin-top: 2px; }

.hint { font-size: 12px; color: var(--text-3); }
.auth-msg {
  margin-top: 14px;
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  color: #d33;
}
.auth-msg.ok { color: var(--green); }
.auth-foot {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* ===== 主布局 ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 238px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 16px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -.1px;
}
.side-brand .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 11.5px; margin: 0; }

.nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 20px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  text-decoration: none;
  cursor: pointer;
  transition: all .13s;
  user-select: none;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-ico { font-size: 12px; width: 16px; text-align: center; opacity: .85; }

.side-tags { flex: 1; min-height: 0; }
.side-tags-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .6px;
  text-transform: uppercase;
}
.tag-list { display: flex; flex-direction: column; gap: 1px; }
.tag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .13s;
}
.tag-item:hover { background: var(--bg); color: var(--text); }
.tag-item.active { background: var(--bg); color: var(--text); font-weight: 500; }
.tag-item .tag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tag-item .tag-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-item .tag-n { font-size: 11px; color: var(--text-3); }
.tag-empty { padding: 8px 10px; font-size: 12px; color: var(--text-3); }

.side-user {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a86ff, #7c53d6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.side-user-info { flex: 1; min-width: 0; }
.side-user-mail {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 主区 ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-ico {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  font-size: 16px;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 12px 8px 34px;
  font-size: 13.5px;
  transition: all .15s;
}
.search-wrap input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.seg {
  display: flex;
  background: var(--bg);
  border-radius: 9px;
  padding: 3px;
}
.seg-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13px;
  transition: all .15s;
}
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.stats {
  display: flex;
  gap: 10px;
  padding: 16px 26px 0;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  min-width: 104px;
}
.stat-n { font-size: 20px; font-weight: 600; letter-spacing: -.4px; }
.stat-l { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.content { flex: 1; overflow-y: auto; padding: 20px 26px 40px; }

.list-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 14px;
}
.list-head h2 { font-size: 15px; font-weight: 600; }
.count { font-size: 12.5px; color: var(--text-3); }

/* ===== 卡片 ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: all .16s;
  cursor: pointer;
  position: relative;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-ico {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.ico-link { background: var(--accent-soft); }
.ico-file { background: var(--amber-soft); }
.ico-note { background: var(--violet-soft); }

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -.1px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-url {
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.card-desc {
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
}
.card-owner { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mini-avatar {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a86ff, #7c53d6);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.card-owner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.card-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.card-count { display: flex; align-items: center; gap: 3px; }

/* ===== 空状态 ===== */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 70px 20px;
  color: var(--text-3);
}
.empty-ico { font-size: 32px; opacity: .35; margin-bottom: 12px; }
.empty h3 { font-size: 14.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.empty p { font-size: 13px; }

/* ===== 弹窗 ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 35, .38);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; font-weight: 600; letter-spacing: -.1px; }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.type-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.type-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 13px 6px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  transition: all .15s;
}
.type-opt:hover { border-color: var(--border-strong); }
.type-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.type-opt-ico { font-size: 17px; }
.type-opt-t { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.type-opt.active .type-opt-t { color: var(--accent); }

#item-form { display: flex; flex-direction: column; gap: 15px; }
#item-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}
#item-form input[type="text"],
#item-form input[type="url"],
#item-form textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--text);
  transition: all .15s;
  font-weight: 400;
  resize: vertical;
}
#item-form input:focus,
#item-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.file-drop { position: relative; display: block; }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 22px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 400;
  text-align: center;
  transition: all .15s;
}
.file-drop:hover .file-drop-inner { border-color: var(--accent); background: var(--accent-soft); }
.file-drop-ico { font-size: 18px; }
.file-picked { font-size: 12px; color: var(--green); font-weight: 400; }
.file-picked ul { list-style: none; display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.file-picked li { display: flex; align-items: center; gap: 6px; color: var(--text-2); }

.field-tags-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 7px; display: block; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick {
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  transition: all .15s;
}
.tag-pick:hover { border-color: var(--text-3); }
.tag-pick.on { color: #fff; font-weight: 500; }

/* ===== 详情 ===== */
.modal-detail { max-width: 620px; }
.detail-sec { margin-bottom: 20px; }
.detail-sec:last-child { margin-bottom: 0; }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.detail-title-row { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.detail-title-row .card-ico { width: 38px; height: 38px; font-size: 17px; }
.detail-title-row h4 { font-size: 16px; font-weight: 600; line-height: 1.4; letter-spacing: -.2px; }
.detail-desc {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--accent);
  font-size: 13px;
  transition: all .15s;
  overflow: hidden;
}
.detail-link:hover { background: var(--accent-soft); border-color: #cddefd; }
.detail-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-files { display: flex; flex-direction: column; gap: 7px; }
.detail-file {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.detail-file-ico { font-size: 17px; flex-shrink: 0; }
.detail-file-info { flex: 1; min-width: 0; }
.detail-file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-file-size { font-size: 11.5px; color: var(--text-3); }

/* ===== 讨论 ===== */
.comments { display: flex; flex-direction: column; gap: 12px; }
.comment {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.comment:first-child { border-top: none; padding-top: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.comment-who { font-weight: 600; color: var(--text); }
.comment-when { color: var(--text-3); }
.comment-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.comment-del {
  background: none; border: none;
  color: var(--text-3);
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 5px;
  margin-left: auto;
  opacity: 0;
  transition: all .15s;
}
.comment:hover .comment-del { opacity: 1; }
.comment-del:hover { color: #d33; background: #fdf2f2; }

.comment-form { display: flex; gap: 9px; align-items: flex-end; margin-top: 4px; }
.comment-form textarea {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  transition: all .15s;
}
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.detail-actions {
  display: flex;
  gap: 9px;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1c1f23;
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #c0392b; }

/* ===== 加载 ===== */
.loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px;
  color: var(--text-3);
  font-size: 13px;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 预览模式提示条 ===== */
#demo-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 18px;
  background: linear-gradient(90deg, #2f6df6, #7c53d6);
  color: #fff;
  font-size: 12.5px;
  box-shadow: 0 2px 10px rgba(47, 109, 246, .25);
}
#demo-banner .demo-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}
#demo-banner span:nth-child(2) { flex: 1; }
#demo-banner button {
  background: rgba(255, 255, 255, .18);
  border: none;
  color: #fff;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  transition: background .15s;
}
#demo-banner button:hover { background: rgba(255, 255, 255, .3); }

/* 提示条占了顶部空间，把应用整体下移 */
body:has(#demo-banner) .app { padding-top: 38px; box-sizing: border-box; }
body:has(#demo-banner) .auth-screen { padding-top: 62px; }

/* ===================================================================
   消息与好友模块
   =================================================================== */

/* 导航角标 */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== 聊天整体布局 ===== */
.chat-layout {
  display: flex;
  padding: 0 !important;
  overflow: hidden;
}

/* 左侧会话列表 */
.conv-list {
  width: 246px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
}
.conv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px 10px;
}
.conv-head h3 { font-size: 14px; font-weight: 600; }
.conv-search { padding: 0 12px 10px; }
.conv-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  transition: all .15s;
}
.conv-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.conv-items { flex: 1; overflow-y: auto; padding: 0 8px 12px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .13s;
  position: relative;
}
.conv-item:hover { background: rgba(0, 0, 0, .035); }
.conv-item.active { background: var(--accent-soft); }

.conv-body { flex: 1; min-width: 0; }
.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time { font-size: 10.5px; color: var(--text-3); flex-shrink: 0; }
.conv-last {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-unread {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pink);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 右侧对话窗口 */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.chat-empty h3 { font-size: 14.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.chat-empty p { font-size: 13px; }

.chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-peer { flex: 1; min-width: 0; }
.chat-peer-name { font-size: 14px; font-weight: 600; }
.chat-peer-sub { font-size: 11.5px; color: var(--text-3); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
}

/* 消息气泡 */
.msg-row { display: flex; gap: 9px; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }

.msg-col { display: flex; flex-direction: column; gap: 4px; max-width: 66%; min-width: 0; }
.msg-row.mine .msg-col { align-items: flex-end; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.msg-row.mine .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 5px;
}

.msg-time { font-size: 10.5px; color: var(--text-3); padding: 0 3px; }

/* 分享卡片消息 */
.msg-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  border-bottom-left-radius: 5px;
  cursor: pointer;
  transition: all .15s;
  min-width: 220px;
}
.msg-row.mine .msg-card {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 5px;
}
.msg-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.msg-card-ico {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.msg-card-body { flex: 1; min-width: 0; }
.msg-card-t {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.msg-card-s {
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-card-tagline {
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 3px;
}

/* 日期分隔 */
.msg-day {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  margin: 4px 0;
}

/* 输入区 */
.chat-foot {
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
  flex-shrink: 0;
  background: var(--surface);
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}
.chat-input-row textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  transition: all .15s;
}
.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 分享预览条 */
.share-preview { margin-bottom: 10px; }
.share-preview-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--accent-soft);
  border: 1px solid #cddefd;
  border-radius: 10px;
}
.share-preview-ico { font-size: 15px; }
.share-preview-text { flex: 1; min-width: 0; }
.share-preview-t {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-preview-s { font-size: 11px; color: var(--text-2); }

/* ===== 分享选择弹窗 ===== */
.modal-share { max-width: 520px; }
.share-search { margin-bottom: 14px; }
.share-search input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: all .15s;
}
.share-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.share-picker { display: flex; flex-direction: column; gap: 7px; }
.share-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.share-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.share-opt-ico {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.share-opt-body { flex: 1; min-width: 0; }
.share-opt-t {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
  color: var(--text);
}
.share-opt-s {
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== 好友页 ===== */
.friends-wrap { max-width: 660px; }

.friend-add {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 22px;
}
.friend-add h3 { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.friend-add-hint { font-size: 12.5px; color: var(--text-3); margin-bottom: 13px; }
.friend-add-row { display: flex; gap: 9px; }
.friend-add-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  transition: all .15s;
}
.friend-add-row input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.friend-section { margin-bottom: 24px; }
.friend-section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 11px;
}
.friend-section-head h3 { font-size: 14px; font-weight: 600; }

.friend-list { display: flex; flex-direction: column; gap: 8px; }

.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.friend-info { flex: 1; min-width: 0; }
.friend-mail {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.friend-state { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.friend-actions { display: flex; gap: 8px; flex-shrink: 0; }
.friend-actions .btn-primary,
.friend-actions .btn-ghost { padding: 6px 13px; font-size: 12.5px; }

/* 响应式：窄屏下会话列表变窄 */
@media (max-width: 1100px) {
  .conv-list { width: 200px; }
  .msg-col { max-width: 80%; }
}

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .stats { padding: 14px 16px 0; }
  .content { padding: 16px 16px 32px; }
  .search-wrap { order: 3; flex-basis: 100%; }
  .cards { grid-template-columns: 1fr; }

  /* 窄屏：会话列表折叠到上方 */
  .chat-layout { flex-direction: column; }
  .conv-list {
    width: 100%;
    max-height: 220px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .msg-col { max-width: 82%; }
}
