:root {
  --bg: #efeae2;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f9f6e;
  --brand-dark: #0b7f57;
  --mine: #d1f4e0;
  --panel: #ffffff;
  --danger: #dc2626;
  --ok: #166534;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); background: #f3f4f6; }
button, input { font: inherit; }
a { color: var(--brand-dark); }
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(420px, 100%); background: #fff; border-radius: 16px; padding: 28px;
  box-shadow: 0 10px 30px rgba(15,23,42,.08);
}
.auth-card h1 { margin: 0 0 8px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.auth-card input, .sidebar input, .composer input, #user-q, #text, #search-user {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.auth-card button, .sidebar button, .composer button, #load-older {
  border: 0; border-radius: 10px; padding: 10px 12px; background: var(--brand); color: #fff; cursor: pointer;
}
.muted { color: var(--muted); font-size: 13px; }
.banner { padding: 8px 10px; border-radius: 8px; }
.banner.error { background: #fee2e2; color: #991b1b; }
.banner.ok { background: #dcfce7; color: #166534; }
.field-error { color: #991b1b; font-size: 13px; }
.app-shell { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  display: flex; gap: 12px; align-items: center; padding: 10px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.spacer { flex: 1; }
.inline { display: inline; }
.linkish { background: none; border: 0; color: var(--brand-dark); cursor: pointer; padding: 0; }
.app-body { flex: 1; display: grid; grid-template-columns: 280px 1fr; min-height: 0; }
.sidebar { background: #f7f7f7; border-right: 1px solid #e4e4e4; padding: 14px; overflow: auto; }
.sidebar form { display: flex; flex-direction: column; gap: 8px; }
#thread-list { list-style: none; margin: 0; padding: 0; }
#thread-list li {
  padding: 10px; background: #fff; border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
#thread-list li.active { outline: 2px solid #bbf7d0; }
.unread { background: #ecfdf5; color: var(--brand-dark); border-radius: 999px; padding: 0 6px; font-size: 12px; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 14px 18px; background: rgba(255,255,255,.7); border-bottom: 1px solid #e8e0d5; }
.log { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-direction: column; max-width: 72%; }
.row.mine { align-self: flex-end; }
.bubble { background: #fff; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.row.mine .bubble { background: var(--mine); }
.meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
#composer { display: flex; gap: 8px; padding: 12px; background: #fff; }
#composer input { flex: 1; }
#load-older { margin: 8px auto; }
.console-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; overflow: auto; }
.panel { background: #0b1220; color: #d1d5db; border-radius: 12px; padding: 12px; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 8px; color: #fff; font-size: 14px; }
.panel pre { white-space: pre-wrap; font-size: 12px; }
@media (max-width: 720px) {
  .app-body, .console-grid { grid-template-columns: 1fr; }
  .sidebar { max-height: 36vh; }
}
