/* ---------- Font Roboto (lưu ngay trên máy chủ, có tiếng Việt) ---------- */
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/roboto-vietnamese-400-normal.woff2) format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/roboto-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/roboto-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/roboto-vietnamese-500-normal.woff2) format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/roboto-latin-ext-500-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/roboto-latin-500-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/roboto-vietnamese-700-normal.woff2) format('woff2');
  unicode-range: U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/roboto-latin-ext-700-normal.woff2) format('woff2');
  unicode-range: U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Roboto'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/roboto-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* ---------- Màu sắc ---------- */
:root {
  --bg: #f1f1f1;
  --panel: #ffffff;
  --border: #e6e6e6;
  --text: #000000;
  --muted: #707579;
  --accent: #3390ec;
  --accent-text: #ffffff;
  --hover: #f4f4f5;
  --active: #3390ec;
  --online: #0ac630;
  --error: #e53935;
  --bubble-in: #ffffff;
  --bubble-out: #eeffde;
  --bubble-out-meta: #4fae4e;
  --bubble-in-meta: #a0acb6;
  --chat-bg: #a8c38b;
  --chat-bg-2: #d3dfa4;
  --chat-bg-3: #8fbf9f;
  --chat-pattern: rgb(255 255 255 / .16);
  --date-pill: rgb(76 104 64 / .55);
  --composer-bg: #ffffff;
  --shadow: 0 1px 2px rgb(16 35 47 / .15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1621;
    --panel: #17212b;
    --border: #0f1720;
    --text: #f5f5f5;
    --muted: #7f91a4;
    --accent: #5288c1;
    --hover: #202b36;
    --active: #2b5278;
    --bubble-in: #182533;
    --bubble-out: #2b5278;
    --bubble-out-meta: #7da8d3;
    --bubble-in-meta: #6d7f8f;
    --chat-bg: #0e1621;
    --chat-bg-2: #13202d;
    --chat-bg-3: #0c1520;
    --chat-pattern: rgb(255 255 255 / .03);
    --date-pill: rgb(30 44 58 / .85);
    --composer-bg: #17212b;
    --shadow: 0 1px 2px rgb(0 0 0 / .35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px; line-height: 1.35;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; }
.primary { background: var(--accent); color: var(--accent-text); padding: 11px 18px; font-weight: 500; }
.primary:hover { filter: brightness(1.07); }
.ghost { background: transparent; color: var(--muted); padding: 6px 10px; }
.ghost:hover { background: var(--hover); }
input, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- Đăng nhập ---------- */
.auth {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(135deg, var(--chat-bg-2), var(--chat-bg) 55%, var(--chat-bg-3));
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); padding: 30px 28px;
  border-radius: 18px; box-shadow: 0 10px 40px rgb(0 0 0 / .12);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-card h1 { margin: 0 0 4px; text-align: center; font-size: 24px; font-weight: 500; }
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--hover); border-radius: 12px; padding: 4px; }
.tab { background: transparent; color: var(--muted); padding: 8px; font-weight: 500; }
.tab.active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.error { color: var(--error); margin: 0; min-height: 1.2em; font-size: 14px; }

/* ---------- Bố cục ---------- */
.app { height: 100%; display: grid; grid-template-columns: 340px 1fr; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 10px 8px 6px 14px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me .avatar { width: 38px; height: 38px; font-size: 15px; }
.me strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 16px; }
.search {
  margin: 4px 12px 8px; width: auto; border-radius: 22px; padding: 9px 16px;
  background: var(--hover); border-color: transparent;
}
.search:focus { background: var(--panel); }

/* Danh sách cuộc trò chuyện */
.user-list { list-style: none; margin: 0; padding: 0 6px 8px; overflow-y: auto; flex: 1; }
.user-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; cursor: pointer;
}
.user-item:hover { background: var(--hover); }
.user-item .avatar { width: 54px; height: 54px; font-size: 20px; }
.user-info { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: center; }
.user-info .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info .item-time { font-size: 12px; color: var(--muted); }
.user-info .preview {
  font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  grid-column: 1 / -1;
}
.user-info .preview.with-badge { grid-column: 1; }
.user-info .preview .you { color: var(--accent); }
.user-item.has-unread .preview { color: var(--text); }
.badge {
  background: var(--online); color: #fff; font-size: 12px; font-weight: 500;
  border-radius: 999px; min-width: 22px; height: 22px; padding: 0 7px; display: grid; place-items: center;
}
.user-item.active { background: var(--active); }
.user-item.active .name, .user-item.active .preview, .user-item.active .item-time,
.user-item.active .preview .you { color: #fff; }
.user-item.active .badge { background: #fff; color: var(--active); }

.avatar {
  position: relative; flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 500; font-size: 17px;
  background-image: linear-gradient(rgb(255 255 255 / .18), rgb(0 0 0 / .05));
}
.avatar.online::after {
  content: ""; position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--online); border: 2px solid var(--panel);
}

/* Khung chat */
.chat {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 12px 12px, var(--chat-pattern) 2px, transparent 2.5px),
    radial-gradient(circle at 42px 38px, var(--chat-pattern) 3px, transparent 3.5px),
    linear-gradient(135deg, var(--chat-bg-2) 0%, var(--chat-bg) 50%, var(--chat-bg-3) 100%);
  background-size: 56px 56px, 74px 74px, 100% 100%;
}
.chat .empty {
  margin: auto; padding: 6px 14px; text-align: center; font-size: 14px; color: #fff;
  background: var(--date-pill); border-radius: 14px;
}
.user-list .empty { color: var(--muted); padding: 16px; text-align: center; font-size: 14px; }
.conversation { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.chat-head strong { font-weight: 500; font-size: 16px; }
.status { font-size: 13px; color: var(--muted); }
.back { display: none; font-size: 22px; }
.ttl-note {
  text-align: center; font-size: 12px; color: var(--muted); padding: 4px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}

/* Tin nhắn */
.messages {
  flex: 1; overflow-y: auto; padding: 12px max(16px, calc((100% - 760px) / 2)) 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.day-sep {
  align-self: center; margin: 10px 0 6px; padding: 3px 10px; border-radius: 12px;
  font-size: 13px; font-weight: 500; color: #fff; background: var(--date-pill);
}
.msg { max-width: min(78%, 520px); display: flex; flex-direction: column; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msg.out .msg-row { flex-direction: row-reverse; }

.bubble {
  position: relative; padding: 6px 10px 7px 11px; border-radius: 14px; box-shadow: var(--shadow);
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; min-width: 0;
}
.msg.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 4px; }
/* "Đuôi" bong bóng */
.msg.in .bubble:not(.image):not(.big)::before,
.msg.out .bubble:not(.image):not(.big)::before {
  content: ""; position: absolute; bottom: 0; width: 10px; height: 14px;
}
.msg.in .bubble:not(.image):not(.big)::before {
  left: -7px; background: radial-gradient(circle at 0 0, transparent 9.5px, var(--bubble-in) 10px);
}
.msg.out .bubble:not(.image):not(.big)::before {
  right: -7px; background: radial-gradient(circle at 100% 0, transparent 9.5px, var(--bubble-out) 10px);
}

/* Giờ gửi + ✓ nằm trong bong bóng, góc dưới phải */
.bubble .meta {
  float: right; margin: 6px 0 -4px 10px; font-size: 12px; line-height: 1; white-space: nowrap;
  color: var(--bubble-in-meta); user-select: none; position: relative; top: 3px;
}
.msg.out .bubble .meta { color: var(--bubble-out-meta); }
.meta .ticks { margin-left: 3px; letter-spacing: -3px; font-size: 13px; }
.meta .ttl { font-variant-numeric: tabular-nums; margin-right: 6px; opacity: .9; }
.meta .ttl.soon { color: var(--error); font-weight: 500; opacity: 1; }
.bubble.image .meta, .bubble.big .meta {
  position: absolute; right: 8px; bottom: 8px; top: auto; margin: 0; float: none;
  color: #fff; background: rgb(0 0 0 / .4); padding: 3px 7px; border-radius: 10px;
}
.bubble.big .meta { right: 0; bottom: -4px; }
.msg .bubble.image .meta, .msg .bubble.big .meta { color: #fff; }
.typing { font-size: 13px; color: var(--muted); font-style: italic; padding: 0 16px 6px; min-height: 1.4em; }

/* Trích dẫn (trả lời) nằm trong bong bóng */
.quote {
  display: block; margin: 0 0 5px; padding: 3px 8px 4px; border-radius: 6px; cursor: pointer;
  background: rgb(51 144 236 / .1); border-left: 3px solid var(--accent); font-size: 14px; max-width: 320px;
}
.msg.out .quote { background: rgb(79 174 78 / .14); border-left-color: var(--bubble-out-meta); }
.quote-name { font-weight: 500; font-size: 13px; color: var(--accent); }
.msg.out .quote-name { color: var(--bubble-out-meta); }
.quote-text { color: var(--text); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble.image .quote { margin: 2px 2px 4px; }
@media (prefers-color-scheme: dark) {
  .msg.out .quote { background: rgb(255 255 255 / .08); }
}
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px #fbbf24; } 100% { box-shadow: var(--shadow); } }

.reply-btn {
  flex: none; background: rgb(0 0 0 / .18); color: #fff; font-size: 15px; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%; opacity: 0; transition: opacity .12s;
}
.msg:hover .reply-btn, .reply-btn:focus-visible { opacity: .85; }
.reply-btn:hover { opacity: 1; background: rgb(0 0 0 / .3); }
@media (pointer: coarse) { .reply-btn { opacity: .5; } }

/* Ô soạn tin */
.composer {
  position: relative; display: flex; align-items: flex-end; gap: 4px;
  margin: 4px max(12px, calc((100% - 760px) / 2)) 12px; padding: 4px 6px 4px 8px;
  background: var(--composer-bg); border-radius: 18px; box-shadow: var(--shadow);
}
.composer textarea {
  flex: 1; min-width: 0; resize: none; max-height: 160px; border: 0; background: transparent;
  padding: 11px 6px; box-shadow: none !important;
}
.composer .primary {
  flex: none; width: 42px; height: 42px; padding: 0; border-radius: 50%; margin-bottom: 1px;
  display: grid; place-items: center; font-size: 0; /* ẩn chữ "Gửi", hiện biểu tượng */
}
.composer .primary::before {
  content: ""; width: 20px; height: 20px; margin-left: 3px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 20.5 22 12 2.5 3.5 2.5 10l13 2-13 2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 20.5 22 12 2.5 3.5 2.5 10l13 2-13 2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.reply-bar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px;
  margin: 0 max(12px, calc((100% - 760px) / 2)) -8px; position: relative; z-index: 1;
  background: var(--composer-bg); border-radius: 14px 14px 0 0;
}
.reply-info { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding-left: 10px; }
.reply-label { font-size: 13px; color: var(--accent); font-weight: 500; }
.reply-label b { font-weight: 500; }
.reply-text { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ô mật khẩu là ô chữ thường được che ký tự, để trình duyệt không hỏi lưu mật khẩu */
.secret { -webkit-text-security: disc; text-security: disc; font-family: system-ui, sans-serif; letter-spacing: 1px; }
.secret::placeholder { letter-spacing: normal; }

/* Không thao tác vài giây: làm mờ nội dung tin nhắn & bản xem trước (chạm là hiện lại) */
.app.shaded .messages,
.app.shaded .user-info,
.app.shaded #peer-name { filter: blur(9px); }
.app.shaded .reply-text { filter: blur(6px); }

/* ---------- Bảo mật: khóa màn hình & tự hủy ---------- */
/* Khi khóa: ẩn hẳn khung chat và phủ nền tối đặc. Không dùng filter/transition
   vì chúng làm chậm khung hình đầu tiên — màn che phải hiện ngay lập tức. */
.app.locked { visibility: hidden; pointer-events: none; user-select: none; }
.lock {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: #0b0c0f radial-gradient(circle at 50% 40%, #1b1e24 0%, #0b0c0f 70%);
}
.lock .auth-card { box-shadow: 0 10px 40px rgb(0 0 0 / .6); text-align: center; }
.lock h2 { margin: 0; font-weight: 500; }
.lock-icon { font-size: 40px; }
.muted { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- Mã hóa đầu-cuối ---------- */
.safety-btn { margin-left: auto; white-space: nowrap; }
.safety-dialog { border: 0; padding: 0; background: transparent; }
.safety-dialog::backdrop { background: rgb(0 0 0 / .4); }
.safety-dialog h2 { margin: 0; text-align: center; font-weight: 500; }
.safety-code {
  font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: 1px; text-align: center;
  display: grid; grid-template-columns: repeat(3, auto); justify-content: center; gap: 6px 16px;
  word-spacing: 16px; padding: 8px 0;
}
.bubble.failed { font-style: italic; opacity: .8; }

/* ---------- Biểu tượng cảm xúc ---------- */
.emoji-btn { font-size: 22px; line-height: 1; padding: 9px 6px; flex: none; color: var(--muted); }
.emoji-btn:hover { background: transparent; filter: brightness(1.1); }
.emoji-panel {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 5;
  width: min(360px, calc(100vw - 24px)); background: var(--panel);
  border-radius: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / .18);
  display: flex; flex-direction: column; overflow: hidden;
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 4px; gap: 2px; overflow-x: auto; }
.emoji-tab { background: transparent; font-size: 20px; padding: 6px; flex: 1; min-width: 34px; border-radius: 8px; }
.emoji-tab:hover { background: var(--hover); }
.emoji-tab.active { background: var(--hover); box-shadow: inset 0 -2px 0 var(--accent); }
.emoji-title { font-size: 12px; color: var(--muted); padding: 8px 12px 2px; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  padding: 4px 8px 8px; height: 240px; overflow-y: auto; overflow-x: hidden; align-content: start;
}
.emoji-item { background: transparent; font-size: 24px; line-height: 1; padding: 6px 0; border-radius: 8px; }
.emoji-item:hover { background: var(--hover); transform: scale(1.15); }
.emoji-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }
.bubble.big { background: transparent !important; box-shadow: none; font-size: 44px; line-height: 1.15; padding: 2px 4px 14px; }

/* ---------- Thông báo & thời gian tự khóa ---------- */
.push-btn {
  margin: 0 12px 8px; padding: 9px 12px; background: rgb(51 144 236 / .1); color: var(--accent);
  font-weight: 500; font-size: 14px; text-align: left;
}
.push-btn.warn { background: #fff4e5; color: #8a4b00; }
@media (prefers-color-scheme: dark) { .push-btn.warn { background: #3a2a12; color: #f5c26b; } }
.push-help {
  margin: 0 12px 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45;
  background: var(--hover); border-radius: 12px;
}
.push-help ol { margin: 6px 0; padding-left: 20px; }
.push-help p { margin: 6px 0; color: var(--muted); }
.push-status { color: var(--text) !important; }
.push-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.push-actions .primary { padding: 7px 14px; font-size: 14px; }
.push-test { border: 1px solid var(--border); }
.head-actions { display: flex; align-items: center; gap: 0; flex: none; }
.bell-btn { font-size: 18px; padding: 4px 6px; opacity: .55; }
.bell-btn.on { opacity: 1; }
.logout-btn { padding: 6px 8px; }
.locktime-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 8px 0; }
.locktime-options button {
  background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 7px 4px; font-size: 13px;
}
.locktime-options button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 500; }
.nolock-chip { color: #b45309; font-weight: 500; white-space: nowrap; }
.nolock-chip b { font-variant-numeric: tabular-nums; }
.nolock-chip button { background: transparent; color: inherit; padding: 0 5px; font-size: 12px; border-radius: 6px; }
.nolock-chip button:hover { background: rgb(0 0 0 / .08); }
@media (prefers-color-scheme: dark) { .nolock-chip { color: #f5c26b; } }
#locktime-btn { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#locktime-btn.active { color: #b45309; font-weight: 500; background: #fff4e5; }

/* ---------- Bạn bè ---------- */
.friends-btn { position: relative; }
.mini-badge {
  position: absolute; top: 0; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--error); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px;
}
.friend-form { display: flex; gap: 6px; margin: 6px 0; }
.friend-form input { padding: 8px 10px; font-size: 14px; }
.friend-form .primary { flex: none; padding: 8px 12px; font-size: 14px; }
.friend-requests { list-style: none; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.friend-requests li { display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 6px 8px; border-radius: 10px; }
.friend-requests .avatar { width: 34px; height: 34px; font-size: 14px; }
.friend-requests .who { flex: 1; min-width: 0; }
.friend-requests .who small { display: block; color: var(--muted); }
.friend-requests button { padding: 6px 10px; font-size: 13px; }
.friend-requests .accept { background: var(--accent); color: #fff; }
.friend-requests .none { background: transparent; color: var(--muted); padding: 2px 0; }
.kicked-note { color: #b45309 !important; }

/* ---------- Ảnh ---------- */
.emoji-btn:disabled { opacity: .4; cursor: wait; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-block; } }
.bubble.image { padding: 3px; width: fit-content; }
.bubble.image img {
  display: block; max-width: 280px; width: auto; height: auto; max-height: 360px;
  border-radius: 11px; cursor: zoom-in; background: var(--hover);
}
.viewer {
  position: fixed; inset: 0; z-index: 8; background: rgb(0 0 0 / .92);
  display: grid; place-items: center; padding: 12px; cursor: zoom-out;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.app.shaded .viewer img { filter: blur(14px); }

/* ---------- Điện thoại ---------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .back { display: inline-block; }
  .chat-head { padding: 6px 8px; gap: 8px; }
  .composer { margin: 4px 6px 8px; padding: 3px 4px 3px 4px; gap: 0; }
  .reply-bar { margin: 0 6px -8px; }
  .emoji-btn { padding: 8px 4px; font-size: 21px; }
  .messages { padding: 10px 10px 8px; }
  .msg { max-width: 86%; }
  .bubble.image img { max-width: 230px; }
}
