:root {
  --accent: #3390ec;
  --accent-dark: #2b7cd3;
  --bg: #ffffff;
  --side-bg: #ffffff;
  --chat-bg: #e7ebf0;
  --bubble: #ffffff;
  --bubble-own: #eeffde;
  --text: #16191c;
  --muted: #707579;
  --border: #e6ecf2;
  --ok: #2f9e44;
  --err: #d6455b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--chat-bg);
}
[v-cloak] { display: none; }
button {
  padding: 9px 16px; font: inherit; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--accent-dark); border: 1px solid var(--border); }
button.ghost:hover { background: #f2f7fd; }
button.danger { background: transparent; color: var(--err); border: 1px solid var(--border); }
button.small { padding: 6px 12px; font-size: 13px; }
input[type=text], input[type=password], input[type=search] {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff;
}
input:focus { border-color: var(--accent); }
.err { color: var(--err); font-size: 13px; margin-top: 8px; }
.ok { color: var(--ok); }
.muted { color: var(--muted); }

.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 14px;
  padding: 28px; box-shadow: 0 8px 30px rgba(16, 35, 57, .12);
}
.gate-card h1 { font-size: 21px; margin: 0 0 4px; }
.gate-card .sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.gate-card input { margin-bottom: 10px; }
.gate-card button { width: 100%; margin-top: 6px; }
.gate-card .hint { font-size: 13px; color: var(--muted); margin-top: 12px; }
.gate-card .hint a { color: var(--accent-dark); }

.layout { height: 100vh; display: flex; }
.sidebar {
  width: 330px; flex: none; background: var(--side-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.side-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.side-head .row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.side-head h2 { font-size: 16px; margin: 0; flex: 1; }
.icon-btn {
  width: 32px; height: 32px; padding: 0; line-height: 1; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--muted); border-radius: 50%; font-size: 18px;
}
.icon-btn:hover { background: #f0f4f8; color: var(--text); }
.icon-btn.on { color: var(--accent); }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid #f4f7fa;
}
.chat-item:hover { background: #f6f9fc; }
.chat-item.active { background: var(--accent); color: #fff; }
.chat-item.active .preview, .chat-item.active .time { color: rgba(255, 255, 255, .8); }
.avatar {
  width: 42px; height: 42px; flex: none; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-top { display: flex; align-items: baseline; gap: 6px; }
.chat-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { font-size: 12px; color: var(--muted); flex: none; }
.preview { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.pill.draft-pill { background: var(--ok); }
.chat-item.active .pill { background: #fff; color: var(--accent); }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: #fff; border-bottom: 1px solid var(--border);
}
.chat-head .title { font-weight: 600; }
.chat-head .star.on { color: #f0a91b; }
.chat-head .star-note { flex: 1; font-size: 12px; }
.chat-head .title + label { margin-left: auto; }
.chat-head label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.messages { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }
.day { text-align: center; margin: 12px 0; }
.day span { background: rgba(0, 0, 0, .12); color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 10px; }
.msg-row { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 10px; }
.msg-row.own { align-items: flex-end; }
.bubble {
  max-width: 72%; padding: 7px 11px 5px; border-radius: 12px; background: var(--bubble);
  box-shadow: 0 1px 1px rgba(16, 35, 57, .08);
}
.msg-row.own .bubble { background: var(--bubble-own); }
.bubble .who { font-size: 13px; font-weight: 600; color: var(--accent-dark); margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .text.media { color: var(--muted); font-style: italic; }
.bubble .stamp { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.bubble.targeted { box-shadow: 0 0 0 2px var(--accent); }
.reply-ref {
  border-left: 3px solid var(--accent); padding-left: 8px; margin-bottom: 4px;
  font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.draft {
  max-width: 72%; margin: 6px 0 4px auto; padding: 10px 12px;
  background: #fff; border: 1px solid var(--accent); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 35, 57, .1);
}
.draft.sent { border-color: var(--border); background: #f7faf7; }
.draft-head { font-size: 12px; font-weight: 700; color: var(--accent-dark); margin-bottom: 6px; }
.draft.sent .draft-head { color: var(--ok); }
.draft .note { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.draft textarea {
  width: 100%; min-height: 70px; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; resize: vertical; outline: none;
}
.draft textarea:focus { border-color: var(--accent); }
.draft-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.draft-actions .state { font-size: 12px; color: var(--muted); }
.draft .sent-text { white-space: pre-wrap; font-size: 14px; }
.loose-head { text-align: center; font-size: 12px; color: var(--muted); margin: 6px 0; }

.empty { color: var(--muted); text-align: center; margin-top: 40px; }

.modal {
  position: fixed; inset: 0; background: rgba(15, 25, 38, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 520px;
  max-height: 86vh; overflow-y: auto;
}
.modal-card h3 { margin: 0 0 14px; font-size: 17px; }
.modal-card .section { margin-bottom: 18px; }
.modal-card .section-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pick-list { max-height: 40vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px;
  border-bottom: 1px solid #f4f7fa; cursor: pointer;
}
.pick:last-child { border-bottom: 0; }
.pick input { width: 16px; height: 16px; accent-color: var(--accent); }
.pick .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .type { font-size: 12px; color: var(--muted); }
.limit-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.limit-row input { width: 90px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report { font-size: 13px; margin-top: 10px; }

@media (max-width: 720px) {
  .sidebar { width: 100%; }
  .layout.has-chat .sidebar { display: none; }
  .layout:not(.has-chat) .chat { display: none; }
  .bubble, .draft { max-width: 90%; }
}
