:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #8b95a1;
  --line: #e8eaed;
  --brand: #7ad0c4;
  --brand-ink: #10322d;
  --danger: #c0392b;
}

* {
  box-sizing: border-box;
}

/* 必须带 !important：下面 .center 之类的 display 规则优先级高于浏览器
   自带的 [hidden] 规则，否则 hidden=true 的元素照样显示。 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.login {
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

label {
  display: block;
  font-size: 13px;
  color: #55606c;
}

input,
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  font: inherit;
  color: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

button.primary {
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: #55606c;
}

button.link {
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
}

button.link.danger {
  color: var(--danger);
}

button:hover {
  filter: brightness(0.97);
}

.error {
  margin: 0;
  min-height: 18px;
  color: var(--danger);
  font-size: 12.5px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.spacer {
  flex: 1;
}

.who {
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  padding: 22px 24px;
  align-items: start;
}

.card.wide {
  grid-column: 1 / -1;
}

.card > label + label,
.card > label + button,
.card > .hint + label {
  margin-top: 12px;
}

.card > button.primary {
  margin-top: 14px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c9cdd2;
}

.dot.on {
  background: #2fb37f;
}

.dot.warn {
  background: #e0a13a;
}

.dot.off {
  background: var(--danger);
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 14px 0 0;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  word-break: break-all;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.row input,
.row select {
  margin-top: 0;
  width: auto;
  flex: 1;
  min-width: 140px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
}

td:last-child {
  text-align: right;
  white-space: nowrap;
}

.add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 12px;
}

.add-grid label {
  margin: 0;
}

.add-actions {
  display: flex;
  align-items: end;
}

.add-actions button {
  width: 100%;
}

dialog {
  border: none;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(20, 24, 28, 0.35);
}

dialog .card {
  width: 360px;
}

dialog .card > label + label,
dialog .card > .hint + label {
  margin-top: 12px;
}

.chat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #f7f8fa;
}

.chat-peers {
  background: #fff;
  border-right: 1px solid var(--line);
  overflow: auto;
  max-height: 520px;
}

.chat-peer {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
}

.chat-peer:hover,
.chat-peer.active {
  background: #f3fbf9;
}

.chat-peer .name {
  display: block;
  font-weight: 600;
  font-size: 13px;
}

.chat-peer .preview {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread {
  padding: 14px 16px;
  overflow: auto;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.bubble.them {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
}

.bubble.me {
  align-self: flex-end;
  background: var(--brand);
  color: var(--brand-ink);
}

.bubble .meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.bubble.me .meta {
  color: rgba(16, 50, 45, 0.65);
}

.bubble img {
  max-width: 220px;
  border-radius: 6px;
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(31, 35, 40, 0.9);
  color: #fff;
  font-size: 13px;
}
