:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2129; --muted: #6b7280; --line: #e5e7eb;
  --accent: #0f766e; --mine: #d9fdd3; --theirs: #fff; --error: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #1b1f24; --text: #e6e8eb; --muted: #9aa3ad; --line: #2c3239;
    --accent: #2dd4bf; --mine: #144d37; --theirs: #262c33; --error: #f87171;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; padding: 6px 14px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: grid; gap: 12px; width: 100%; max-width: 360px; }
.card.wide { max-width: 900px; margin: 16px auto; }
.card label { display: grid; gap: 4px; }
.error { color: var(--error); min-height: 1.5em; margin: 0; }
.hint { color: var(--muted); margin: 0; min-height: 1.5em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.tab { background: none; color: var(--text); border-color: transparent; }
.tab.active { border-color: var(--accent); color: var(--accent); }
#me { color: var(--muted); }
.chats-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 53px); }
.chat-list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.filters { display: grid; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#chat-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
#chat-list li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
#chat-list li.active { background: var(--bg); }
#chat-list .name { font-weight: 600; }
#chat-list .meta { color: var(--muted); font-size: 12px; }
.messages-pane { display: flex; flex-direction: column; min-height: 0; }
.chat-title { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); font-weight: 600; }
#messages { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 70%; padding: 6px 10px; border-radius: 8px; background: var(--theirs); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.bubble.mine { align-self: flex-end; background: var(--mine); }
.bubble .when { display: block; font-size: 11px; color: var(--muted); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
@media (max-width: 700px) {
  .chats-layout { grid-template-columns: 1fr; height: auto; }
  .chat-list-pane { max-height: 45vh; }
  .bubble { max-width: 90%; }
}
