:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ea;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --text: #1f2329;
  --muted: #8a9099;
  --in: #ffffff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────── */
.login-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 340px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 26px; text-align: center; }
.login-card .sub { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 13px; }
.login-card input {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn-row button { flex: 1; }
button {
  padding: 11px 14px;
  border: none;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
button.secondary { background: var(--accent-soft); color: var(--accent); }
button:active { transform: translateY(1px); }
.error { color: #d23; font-size: 13px; min-height: 18px; text-align: center; }

/* QR pairing */
.qr-box {
  width: 220px; height: 220px; margin: 4px auto 0; padding: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.qr-box svg { width: 100%; height: 100%; }
.qr-ph { color: var(--muted); font-size: 13px; }
.pair-status { text-align: center; color: var(--muted); font-size: 13px; margin: 4px 0 2px; min-height: 18px; }
.link { display: block; text-align: center; color: var(--accent); font-size: 13px; text-decoration: none; margin-top: 4px; }
.link:hover { text-decoration: underline; }

/* ── App layout ────────────────────────────────────── */
.app-view { display: flex; height: 100%; }
.sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 16px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.online { background: #25c161; }
.dot.offline { background: #c0c4ca; }
.toolbar { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.toolbar input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.toolbar button { width: 38px; padding: 8px 0; background: var(--accent-soft); color: var(--accent); font-size: 16px; }

.conversation-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.conv:hover { background: #fafbfc; }
.conv.active { background: var(--accent-soft); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; }
.conv-addr { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.conv-preview { color: var(--muted); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Thread ────────────────────────────────────────── */
.thread { flex: 1; display: flex; flex-direction: column; }
.thread-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  background: var(--panel);
  min-height: 53px;
}
.thread-body { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); margin: auto; }
.bubble {
  max-width: 70%;
  background: var(--in);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble .meta { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
.bubble.new { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
