/* MsgYap — style.css (v0.7)
 * WhatsApp/Signal-inspired messenger. 5-tab mobile layout, warm palette.
 * Theme tokens are in theme-messenger.css (loads after this file).
 */

:root {
  /* base palette (overridden by theme-messenger.css) */
  --bg: #F5F0E8;
  --panel: #ffffff;
  --ink: #1A1A1A;
  --ink-soft: #667781;
  --line: #E9EDEF;
  --accent: #6C63FF;
  --accent-dark: #5856D6;
  --accent-soft: #EDEDF9;
  --danger: #F44336;
  --success: #25D366;
  --warn-bg: #FFF8E1;
  --warn-ink: #5D4037;
  --side-bg: #ffffff;
  --side-ink: #111b21;
  --header-bg: #F0F2F5;
  --bubble-out: #DCF8C6;
  --bubble-in: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; }
/* Stable mobile viewport: the page itself never scrolls — only .messages does.
   --vvh is updated from visualViewport in app.js so the keyboard never pushes
   the layout around. */
@supports (height: 100dvh) {
  html, body, #app { height: 100dvh; }
}
body {
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  width: 100%;
}
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }
#screen, #overlays { height: 100%; }

/* ---------- generic controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #fff; 
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(88, 86, 214, 0.2);
}
.btn:hover { 
  background: var(--accent-dark); 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(88, 86, 214, 0.3);
}
.btn:active { transform: translateY(0); }
.btn.ghost { 
  background: transparent; color: var(--accent); 
  border: 1.5px solid var(--accent);
  box-shadow: none;
}
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { background: var(--danger); box-shadow: 0 1px 3px rgba(255, 59, 48, 0.2); }
.btn.danger:hover { background: #d32f2f; box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3); }
.btn.small { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn.link { background: none; color: var(--accent); padding: 6px; box-shadow: none; }
.btn[data-disabled] { opacity: .45; cursor: not-allowed; }

/* inline SVG icons (js/icons.js) inherit colour and sit on the text baseline */
.ic { vertical-align: -0.18em; }
.btn .ic { margin-right: 5px; vertical-align: -0.22em; }
.icon-btn .ic, .avatar .ic, .fc-icon .ic, .brand-logo .ic, .empty-art .ic, .ticks .ic { margin: 0; vertical-align: middle; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
  transition: all 0.2s ease;
  background: rgba(0, 0, 0, 0.04);
}
.icon-btn:hover { 
  background: rgba(88, 86, 214, 0.12); 
  transform: scale(1.05);
}
.icon-btn.send { background: var(--accent); color: #fff; }
.icon-btn.send:hover { background: var(--accent-dark); }
.icon-btn.big { 
  width: 56px; height: 56px; font-size: 24px; 
  background: rgba(255,255,255,.14);
}
.icon-btn.big:hover { background: rgba(255,255,255,.26); }
.icon-btn.big.danger { background: var(--danger); }

.chip {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent-dark); white-space: nowrap;
  letter-spacing: 0.3px;
}
.chip.ok { background: #d4edda; color: #155724; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; flex: none; user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.avatar.photo { overflow: hidden; background: var(--line); }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-wrap { position: relative; display: inline-flex; }
.av-wrap .dot {
  position: absolute; right: 0; bottom: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--success); border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.2);
}
.chat-item.active .av-wrap .dot { border-color: var(--accent); }

input, textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; 
  transition: all 0.2s ease;
}
input:focus, textarea:focus { 
  border-color: var(--accent); 
  box-shadow: 0 0 0 3px rgba(88, 86, 214, 0.1);
}
textarea { resize: none; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 12px; }
label input, label textarea { margin-top: 5px; font-weight: 400; color: var(--ink); }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1000px 500px at 80% -10%, #e2e0fb 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px;
  padding: 30px 28px; box-shadow: var(--shadow);
}
.auth-card.center { text-align: center; }
.brand { display: flex; align-items: center; gap: 10px; justify-content: center; }
.brand-logo { font-size: 30px; color: var(--accent); display: inline-flex; }
.brand-name { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.tagline { text-align: center; color: var(--ink-soft); margin: 8px 0 20px; font-size: 13.5px; }
.tabs { display: flex; background: var(--accent-soft); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--ink-soft); font-size: 13.5px; }
.tab.active { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; line-height: 1.5; }
.proto-badge {
  margin-top: 16px; font-size: 11.5px; color: var(--warn-ink); background: var(--warn-bg);
  padding: 7px 10px; border-radius: 8px; text-align: center;
}
.proto-badge.tiny { margin: 0; padding: 4px 8px; }
.lock-name { margin: 10px 0 2px; }
.auth-card.center form { margin-top: 14px; text-align: left; }
.auth-card.center .btn.link { margin-top: 12px; }

.phrase-modal .phrase-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px; line-height: 1.9; letter-spacing: .4px;
  background: var(--accent-soft); border-radius: 12px; padding: 16px 18px; margin: 12px 0;
  transition: filter .2s;
}
.phrase-box.blurred { filter: blur(7px); user-select: none; }
.row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.col { flex-direction: column; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; margin: 12px 0; }
.check input { width: auto; margin-top: 2px; }

/* ---------- main layout ---------- */
.main { display: flex; height: var(--vvh, 100dvh); overflow: hidden; }
.sidebar {
  width: 340px; flex: none; background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  height: 60px; min-height: 60px;
}
.me-chip { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; border-radius: 10px; padding: 6px 10px; }
.me-chip:hover { background: rgba(0,0,0,0.04); }
.side-actions { display: flex; gap: 8px; padding: 12px 14px; }
.side-actions .btn { flex: 1; }
.side-actions .btn { background: var(--accent); color: #fff; }
.side-actions .btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.side-actions .btn.ghost:hover { background: rgba(0,0,0,0.04); }
.search {
  margin: 8px 12px; background: var(--header-bg); border-color: transparent; color: var(--ink);
  border-radius: 8px; padding: 8px 12px;
}
.search::placeholder { color: var(--ink-soft); }
.search:focus { background: #fff; border-color: var(--accent); }
.chat-list { flex: 1; overflow-y: auto; padding: 0; }
.list-empty { color: var(--ink-soft); text-align: center; padding: 30px 16px; font-size: 13.5px; line-height: 1.6; }
.chat-item {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); position: relative;
  transition: background 0.15s ease;
}
.chat-item:hover { background: var(--header-bg); }
.chat-item.active { background: var(--accent-soft); }
.ci-main { flex: 1; min-width: 0; }
.ci-top { display: flex; justify-content: space-between; gap: 8px; }
.ci-name { font-weight: 600; font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { font-size: 12px; color: var(--ink-soft); flex: none; }
.ci-preview { display: block; font-size: 13.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.chat-item.active .ci-preview, .chat-item.active .ci-time { color: var(--accent-dark); }
.unread {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 600;
  min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 6px; flex: none;
}
.side-foot { padding: 10px 14px; border-top: 1px solid var(--line); text-align: center; background: var(--header-bg); }

.chat-pane { 
  flex: 1; display: flex; flex-direction: column; 
  min-width: 0; background: var(--bg);
  overflow: hidden; /* Required for sticky positioning to work */
  height: 100%; /* Ensure full height */
}
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--ink-soft); text-align: center; padding: 30px;
}
.empty-art { font-size: 54px; color: var(--accent); opacity: .6; display: flex; justify-content: center; }
.empty-state h3 { color: var(--ink); }
.empty-state p { max-width: 380px; font-size: 14px; }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--header-bg); border-bottom: 1px solid var(--line);
  height: 60px; min-height: 60px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: sticky; top: 0; z-index: 10;
}
.chat-head-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; border-radius: 10px; padding: 6px 10px; cursor: pointer; }
.chat-head-main:hover { background: rgba(0,0,0,0.04); }
.ch-meta { min-width: 0; flex: 1; }
.ch-name { font-weight: 600; font-size: 16px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.ch-sub { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.ch-sub b { color: var(--accent); font-weight: 500; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.back { display: none; }

/* ---------- composer stability (mobile) ---------- */
.composer {
  position: sticky; bottom: 0; z-index: 5;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* ---------- messages ---------- */
.messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; 
  padding: 16px 12px 8px;
  background-color: var(--chat-bg, #EFE7DD);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='%23d9d3cb' fill-opacity='0.4'%3E%3Cpath d='M20 20h10v10H20zM50 50h10v10H50zM80 20h10v10H80zM110 50h10v10h-10zM140 20h10v10h-10zM170 50h10v10h-10zM20 80h10v10H20zM50 110h10v10H50zM80 80h10v10H80zM110 110h10v10h-10zM140 80h10v10h-10zM170 110h10v10h-10zM20 140h10v10H20zM50 170h10v10H50zM80 140h10v10H80zM110 170h10v10h-10zM140 140h10v10h-10zM170 170h10v10h-10z'/%3E%3C/g%3E%3C/svg%3E");
}
.day-sep {
  text-align: center; font-size: 12px; font-weight: 500; color: var(--ink-soft);
  background: rgba(225,228,228,0.9); display: table; margin: 12px auto; 
  padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}
.msg-row { display: flex; margin-bottom: 4px; animation: msgSlideIn 0.2s ease; }
.msg-row.out { justify-content: flex-end; }
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble {
  max-width: min(65%, 520px); padding: 8px 12px 10px; border-radius: 12px;
  background: var(--bubble-in, #fff); 
  box-shadow: 0 1px 1px rgba(0,0,0,0.08); 
  position: relative;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.bubble.in { 
  border-top-left-radius: 4px;
  background: var(--bubble-in, #fff);
  color: var(--ink, #111B21);
}
.bubble.out { 
  background: var(--bubble-out, #DCF8C6);
  color: var(--ink, #111B21);
  border-top-right-radius: 4px;
}
.bubble.out .meta { color: var(--ink-soft, #667781); }
.bubble.out .ticks { color: var(--ink-soft, #667781); }
.bubble.out .ticks.read, .bubble.out .ticks.delivered { color: var(--tick-read, #53BDE8); }
.bubble .text { display: block; white-space: pre-wrap; line-height: 1.4; font-size: 14.5px; }
.bubble .sender { display: block; font-size: 12.5px; font-weight: 500; color: var(--accent, #6C5CE7); margin-bottom: 2px; }
.bubble .meta { 
  display: inline-flex; gap: 4px; align-items: center; 
  float: right; margin: 4px 0 -4px 8px; 
  font-size: 11px; color: var(--ink-soft, #667781);
}
.ticks { font-size: 16px; color: var(--ink-soft, #667781); display: inline-flex; align-items: center; }
.ticks.read, .ticks.delivered { color: var(--tick-read, #53BDE8); }
.sysnote {
  text-align: center; font-size: 12px; color: var(--ink-soft);
  background: rgba(255,255,255,.9); border-radius: 12px; padding: 10px 16px;
  margin: 12px auto; max-width: 480px; line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.sysnote.warn { color: var(--warn-ink); background: var(--warn-bg); font-weight: 600; }
.img-msg {
  display: block; max-width: 320px; max-height: 260px; border-radius: 12px;
  cursor: zoom-in; margin-bottom: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
}
.img-msg:hover { transform: scale(1.02); }
.file-card {
  display: flex; align-items: center; gap: 12px; 
  background: rgba(255,255,255,.8);
  border: 1px solid var(--line); border-radius: 12px; 
  padding: 10px 14px; margin-top: 4px;
  transition: all 0.2s ease;
}
.file-card:hover { background: rgba(255,255,255,1); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.fc-icon { font-size: 24px; display: inline-flex; align-items: center; color: var(--accent); }
.fc-sub { font-size: 12px; color: var(--ink-soft); }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px;
  background: var(--header-bg); border-top: 1px solid var(--line);
  position: sticky; bottom: 0; z-index: 10;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.composer textarea {
  flex: 1; border-radius: 24px; padding: 10px 16px; max-height: 120px; min-height: 42px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 15px; resize: none;
  transition: all 0.2s ease;
}
.composer textarea:focus { 
  border-color: var(--accent); 
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0,168,132,0.1);
}
.composer .send { 
  color: #fff; background: var(--accent);
  width: 42px; height: 42px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,168,132,0.3);
  flex-shrink: 0;
}
.composer .send:hover { 
  background: var(--accent-dark); 
  transform: scale(1.05);
}

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 24, 20, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal {
  position: relative; width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px; padding: 22px 22px 18px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 18px; margin-bottom: 10px; }
.modal .hint { margin-bottom: 8px; }
.modal-x { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border-radius: 50%; color: var(--ink-soft); font-size: 14px; }
.modal-x:hover { background: var(--bg); }
.safety {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0;
  font-family: ui-monospace, Menlo, monospace; font-size: 13px; text-align: center;
}
.safety span { background: var(--accent-soft); border-radius: 8px; padding: 7px 2px; letter-spacing: 1px; }
.safety.verified span { background: #e3f6e8; color: #1d7a3a; }
.dir-list { max-height: 240px; overflow-y: auto; margin-top: 6px; }
.dir-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 10px; text-align: left; font-weight: 600;
}
.dir-item:hover { background: var(--accent-soft); }
.dir-item.check-row { font-weight: 500; }
.dir-item input { width: auto; }
.member-list { list-style: none; margin-top: 8px; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-weight: 600; }
.settings-row { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.dp-row { margin-top: 6px; gap: 8px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; color: var(--ink-soft); }
.kv b { color: var(--ink); }

/* ---------- calls ---------- */
.call-panel {
  position: fixed; inset: 0; z-index: 60; background: #0d1a16;
  display: flex; align-items: center; justify-content: center;
}
.call-panel video { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.call-panel video.hidden { opacity: 0; pointer-events: none; }
#local-video {
  position: absolute; right: 18px; bottom: 108px; width: 180px; height: 130px;
  object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.3); z-index: 2;
}
.call-info {
  position: relative; z-index: 2; text-align: center; color: #fff;
  background: rgba(13, 26, 22, .55); padding: 26px 40px; border-radius: 18px;
}
.call-info h3 { font-size: 22px; margin: 8px 0 2px; }
.call-info p { font-size: 13px; opacity: .75; }
.call-controls { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; z-index: 3; }

/* ---------- toasts & lightbox ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #17211e; color: #fff; padding: 10px 18px; border-radius: 12px;
  font-size: 13.5px; z-index: 80; box-shadow: var(--shadow); max-width: 90vw;
  animation: toast-in .25s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--accent-dark); }
.toast.gone { opacity: 0; transition: opacity .4s; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.lightbox {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: 86vw; max-width: 360px; transform: translateX(-102%); transition: transform .22s ease; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .back { display: inline-flex; }
  .bubble { max-width: 82%; }
  .messages { padding: 14px 12px 8px; }
}
@media (max-width: 480px) {
  .auth-card { padding: 22px 18px; }
  .safety { grid-template-columns: repeat(3, 1fr); }
  #local-video { width: 120px; height: 90px; }
}

/* ---------- status / stories ---------- */
.status-tray {
  display: flex; gap: 10px; overflow-x: auto; padding: 10px 14px 6px;
  scrollbar-width: none;
}
.status-tray::-webkit-scrollbar { display: none; }
.st-item { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.st-ring {
  position: relative; display: inline-flex; padding: 3px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.22);
}
.st-ring.unseen { border-color: #9b4dff; }
.st-ring.seen { border-color: rgba(255,255,255,.25); }
.st-ring.has { border-color: #9b4dff; }
.st-plus {
  position: absolute; right: -3px; bottom: -2px; width: 15px; height: 15px;
  background: var(--accent); border-radius: 50%; color: #fff; font-size: 11px; font-style: normal;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--side-bg);
}
.st-label { font-size: 10.5px; color: rgba(255,255,255,.65); max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-list { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.status-item { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.status-item img { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 8px; }
.status-item.expired { opacity: .45; }
.st-meta { font-size: 11.5px; color: var(--ink-soft); display: block; margin-top: 6px; }

/* ---------- badges & mode ---------- */
.biz-badge, .ai-badge, .mode-tag {
  font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 6px; vertical-align: middle; margin-left: 4px;
}
.biz-badge { background: #fff3d6; color: #8a6100; }
.ai-badge { background: #eceafd; color: #514cd6; }
.mode-tag { background: rgba(255,255,255,.15); color: #fff; font-size: 9px; padding: 1px 5px; }
.ai-avatar { box-shadow: 0 0 0 2px rgba(155,77,255,.35); }

.set-h { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); margin: 14px 0 8px; }
.mode-switch { display: flex; gap: 8px; margin-bottom: 10px; }
.mode-btn {
  flex: 1; padding: 9px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
  background: var(--bg); color: var(--ink-soft); border: 1.5px solid var(--line);
}
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
label.dim { opacity: .5; }
.ai-advanced { margin: 8px 0 12px; font-size: 13.5px; }
.ai-advanced summary { font-weight: 600; color: var(--accent); cursor: pointer; margin-bottom: 8px; }

/* ---------- calls: rec + watermark ---------- */
.rec-badge {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(192, 53, 92, .92); color: #fff; font-weight: 800; font-size: 12px;
  letter-spacing: 1px; padding: 6px 14px; border-radius: 20px;
  animation: recpulse 1.6s infinite;
}
.rec-badge.hidden { display: none; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.icon-btn.big.rec { border: 2px solid rgba(255,255,255,.35); }
.icon-btn.big.rec.active { background: var(--danger); border-color: #fff; }
.watermark {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-around; align-items: center;
  flex-wrap: wrap; opacity: .16; transform: rotate(-18deg) scale(1.4);
}
.watermark span {
  color: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; padding: 0 20px;
}
.call-sec { font-size: 11px !important; opacity: .85; margin-top: 6px; }

/* ---------- profiles / businesses / ads ---------- */
.prof-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.prof-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  text-align: left; border: 1.5px solid var(--line);
}
.prof-row:hover { border-color: var(--accent); }
.prof-row.active { border-color: var(--accent); background: var(--accent-soft); }
.biz-logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ad-card {
  position: relative; display: block; width: 100%; text-align: left;
  background: linear-gradient(135deg, #f3f1ff, #faf6ff); border: 1.5px solid #d8d3ff;
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.ad-card:hover { border-color: var(--accent); }
.ad-card img, .ad-card video { border-radius: 8px; display: block; margin-bottom: 8px; }
.ad-card.slim { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 6px 0; }
.ad-tag {
  position: absolute; top: 8px; right: 10px; font-size: 9px; font-weight: 800;
  letter-spacing: 1px; background: rgba(81,76,214,.12); color: var(--accent);
  padding: 2px 7px; border-radius: 6px;
}
.ad-card.slim .ad-tag { position: static; margin-left: auto; }
.ad-cta { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
.ad-list { max-height: 40vh; overflow-y: auto; }
.biz-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }

/* ---------- message requests ---------- */
.request-banner { border: 1.5px dashed rgba(255,255,255,.2); }
.request-banner:hover { border-color: var(--accent); }
.request-actions {
  display: flex; gap: 8px; padding: 10px 14px; background: var(--warn-bg);
  border-bottom: 1px solid var(--line); align-items: center;
}
.request-actions p { flex: 1; font-size: 13px; color: var(--warn-ink); margin: 0; }

/* scrollbars */
.chat-list::-webkit-scrollbar, .messages::-webkit-scrollbar, .modal::-webkit-scrollbar, .dir-list::-webkit-scrollbar { width: 8px; }
.chat-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 4px; }
.messages::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb, .dir-list::-webkit-scrollbar-thumb { background: rgba(23,33,30,.18); border-radius: 4px; }

/* ---- mobile layout ---- */
.mobile-content {
  display: none;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding-bottom: var(--nav-h, 64px);
}
.mobile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.mobile-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.3px;
  margin: 0;
}
.mobile-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

@media (max-width: 768px) {
  .mobile-content { display: flex; }
  .sidebar { display: none !important; }
  .chat-pane {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    background: var(--bg);
  }
  .chat-pane.active, body.chat-open .chat-pane { display: flex; }
  body.chat-open .mobile-content { display: none; }
  body.chat-open .tab-nav { display: none !important; }
  body.chat-open .fab { display: none !important; }
  .back { display: inline-flex !important; }
  .bubble { max-width: 85%; }
  .messages { padding: 10px 8px 6px; }
  .chat-head { padding: 8px 12px; min-height: 52px; }
  .composer { padding: 6px 8px; }
}

@media (max-width: 480px) {
  .mobile-title { font-size: 20px; }
  .chat-item { padding: 10px 12px; gap: 10px; }
  .ci-name { font-size: 15px; }
  .bubble { max-width: 90%; font-size: 14px; }
  .icon-btn { width: 36px; height: 36px; font-size: 16px; }
}

/* ========== Phase A: 10 Critical Features ========== */

/* --- Context menu --- */
.context-menu { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.ctx-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--ink); text-align: left; width: 100%;
  border-radius: 8px; transition: background .15s;
}
.ctx-item:hover { background: rgba(0,0,0,.06); }
.ctx-item.danger { color: #ef4444; }
.ctx-item.danger:hover { background: rgba(239,68,68,.08); }

/* --- Reply quote inside bubble --- */
.reply-quote {
  display: flex; flex-direction: column; gap: 2px;
  padding: 6px 10px; margin-bottom: 6px;
  border-left: 3px solid var(--accent);
  background: rgba(0,0,0,.05); border-radius: 6px;
  cursor: pointer; font-size: 12px; max-width: 100%;
}
.reply-quote:hover { background: rgba(0,0,0,.09); }
.rq-from { font-weight: 600; color: var(--accent); font-size: 11px; }
.rq-text { color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Composer reply/edit preview --- */
.composer-preview {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--card);
  border-top: 1px solid var(--line); font-size: 13px;
}
.composer-preview.reply { border-left: 3px solid var(--accent); }
.composer-preview.edit { border-left: 3px solid #ffbe0b; }
.cp-label { font-weight: 600; color: var(--accent); white-space: nowrap; }
.composer-preview.edit .cp-label { color: #ffbe0b; }
.cp-text { flex: 1; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--sub); padding: 0 4px; line-height: 1;
}
.cp-close:hover { color: var(--ink); }

/* --- Reactions --- */
.reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.react-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 12px; font-size: 12px;
  border: 1px solid var(--line); background: var(--card);
  cursor: pointer; transition: all .15s;
}
.react-pill:hover { background: rgba(0,0,0,.06); }
.react-pill.mine { border-color: var(--accent); background: rgba(var(--accent-rgb, 81,76,214),.1); }
.react-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px dashed var(--line); background: none;
  cursor: pointer; font-size: 14px; color: var(--sub);
}
.react-add:hover { border-color: var(--accent); color: var(--accent); }

/* --- Reaction picker grid --- */
.react-picker-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 0;
}
.react-pick {
  font-size: 28px; padding: 8px; border: none; background: none;
  cursor: pointer; border-radius: 12px; transition: all .15s;
}
.react-pick:hover { background: rgba(0,0,0,.08); transform: scale(1.2); }

/* --- Deleted message --- */
.bubble.deleted { opacity: .6; }
.bubble.deleted .text i { color: var(--sub); }

/* --- Edited label --- */
.edited-label { font-size: 10px; color: var(--sub); margin-left: 4px; font-style: italic; }

/* --- Star indicator --- */
.star-indicator { font-size: 12px; color: #ffbe0b; margin-left: 4px; }

/* --- Disappearing timer --- */
.disappear-timer { font-size: 11px; color: var(--sub); margin-left: 4px; opacity: .7; }
.disappear-badge { font-size: 14px; color: var(--accent); margin: 0 4px; }

/* --- Pin banner --- */
.pin-banner {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: rgba(var(--accent-rgb, 81,76,214),.08);
  border-bottom: 1px solid var(--line); font-size: 12px; color: var(--sub);
}
.pin-banner b { color: var(--ink); }

/* --- Search bar --- */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.search-bar input {
  flex: 1; border: none; background: none; font-size: 14px;
  color: var(--ink); outline: none; padding: 6px 0;
}
.search-bar input::placeholder { color: var(--sub); }

/* --- Voice note --- */
.voice-note {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; min-width: 220px;
}
.vn-play {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--accent); color: white;
  cursor: pointer; font-size: 14px; display: flex;
  align-items: center; justify-content: center;
}
.vn-play:hover { opacity: .85; }
.vn-dur { font-size: 11px; color: var(--sub); }

/* --- Highlight on scroll-to-message --- */
.highlight-msg { animation: highlightPulse 2s ease-out; }
@keyframes highlightPulse {
  0% { background: rgba(var(--accent-rgb, 81,76,214),.25); }
  100% { background: transparent; }
}

/* --- Voice recording active state --- */
.voice-stop { animation: recPulse 1s infinite; }
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ========== Phase B: Media & Calls Features ========== */

/* Attach Menu */
.attach-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 0;
}
.attach-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--text);
}
.attach-item:hover {
  background: var(--hover);
  border-color: var(--accent);
}
.attach-icon {
  font-size: 28px;
}

/* --- Camera Modal --- */
.camera-modal {
  max-width: 500px;
}
.camera-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.camera-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rec-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  animation: recPulse 1s infinite;
}

/* --- Media Viewer --- */
.media-viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  z-index: 1000;
}
.media-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.5);
}
.media-counter {
  color: white;
  font-size: 14px;
}
.media-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 12px;
}
.media-viewer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.media-content {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}
.media-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 48px;
  padding: 20px 16px;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 10;
}
.media-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}
.media-prev {
  left: 0;
}
.media-next {
  right: 0;
}
.media-viewer-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}

/* --- Image Editor --- */
.image-editor-modal {
  max-width: 600px;
}
.image-editor-container {
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-editor-container canvas {
  max-width: 100%;
  max-height: 100%;
}
.image-editor-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* --- Sticker Picker --- */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 0;
}
.sticker-item {
  font-size: 32px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.sticker-item:hover {
  background: var(--hover);
  transform: scale(1.1);
}

/* --- GIF Picker --- */
.gif-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}
.gif-item {
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}
.gif-item:hover {
  transform: scale(1.05);
}

/* --- Call History --- */
.call-history-list {
  max-height: 500px;
  overflow-y: auto;
}
.call-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.call-history-item:last-child {
  border-bottom: none;
}
.call-icon {
  font-size: 24px;
}
.call-details {
  flex: 1;
}
.call-peer {
  font-weight: 600;
  margin-bottom: 2px;
}
.call-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========== Phase C: Privacy, Multi-Device & Sticky UI ========== */

/* --- Privacy Controls --- */
.blocked-users-list {
  max-height: 400px;
  overflow-y: auto;
}

.blocked-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.blocked-user-item:last-child {
  border-bottom: none;
}

.blocked-username {
  font-weight: 500;
}

/* --- App Lock Screen --- */
.app-lock-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.lock-content {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.lock-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.lock-content h2 {
  margin: 0 0 10px 0;
  color: #333;
}

.lock-content p {
  margin: 0 0 30px 0;
  color: #666;
}

.lock-content form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lock-content input {
  padding: 16px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
}

.lock-content input:focus {
  outline: none;
  border-color: var(--accent);
}

/* --- Link Device --- */
.link-code-display {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
  margin: 20px 0;
  border: 2px dashed var(--border);
  user-select: all;
}

/* --- Linked Devices --- */
.linked-devices-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.linked-device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.linked-device-item:last-child {
  border-bottom: none;
}

.device-info {
  flex: 1;
}

.device-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.device-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Responsive Design --- */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 320px;
  }
  
  .messages {
    padding: 14px;
  }
  
  .bubble {
    max-width: min(70%, 480px);
  }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 100%;
    border-right: none;
  }
  
  .sidebar.hidden {
    display: none;
  }
  
  .chat-pane {
    width: 100%;
  }
  
  .chat-pane.hidden {
    display: none;
  }
  
  .back {
    display: inline-flex;
  }
  
  .chat-head {
    padding: 8px 12px;
    height: 56px;
    min-height: 56px;
  }
  
  .composer {
    padding: 8px 10px;
  }
  
  .composer textarea {
    font-size: 14px;
    padding: 8px 14px;
  }
  
  .messages {
    padding: 10px 8px 6px;
  }
  
  .bubble {
    max-width: 85%;
    font-size: 14px;
  }
  
  .chat-item {
    padding: 10px 12px;
  }
  
  .side-head {
    height: 56px;
    min-height: 56px;
    padding: 8px 12px;
  }
  
  .modal {
    max-width: 95%;
    padding: 18px;
  }
  
  .modal h2 {
    font-size: 20px;
    margin-bottom: 16px;
  }
}

/* Small mobile (max-width: 480px) */
@media (max-width: 480px) {
  .chat-head {
    padding: 6px 10px;
    gap: 8px;
  }
  
  .ch-name {
    font-size: 15px;
  }
  
  .ch-sub {
    font-size: 12px;
  }
  
  .composer {
    padding: 6px 8px;
    gap: 6px;
  }
  
  .composer textarea {
    padding: 7px 12px;
    font-size: 13.5px;
  }
  
  .composer .send {
    width: 38px;
    height: 38px;
  }
  
  .messages {
    padding: 8px 6px 4px;
  }
  
  .bubble {
    max-width: 90%;
    padding: 5px 7px 7px;
    font-size: 13.5px;
  }
  
  .chat-item {
    padding: 9px 10px;
    gap: 10px;
  }
  
  .ci-name {
    font-size: 14px;
  }
  
  .ci-preview {
    font-size: 13px;
  }
  
  .head-actions {
    gap: 4px;
  }
  
  .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

/* iPad Pro / Large tablets (1024px - 1366px) */
@media (min-width: 1025px) and (max-width: 1366px) {
  .sidebar {
    width: 360px;
  }
  
  .messages {
    padding: 18px 16px 10px;
  }
  
  .bubble {
    max-width: min(60%, 560px);
  }
}

/* Desktop (min-width: 1367px) */
@media (min-width: 1367px) {
  .sidebar {
    width: 400px;
  }
  
  .messages {
    padding: 20px 24px 12px;
  }
  
  .bubble {
    max-width: min(55%, 600px);
  }
  
  .chat-head {
    padding: 12px 20px;
  }
  
  .composer {
    padding: 10px 16px;
  }
}

/* ========== Phase B: Media & Calls Features ========== */

.btn.ghost:hover {
  background: var(--hover);
  border-color: var(--accent);
}

.btn.danger {
  background: #ef4444;
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
}

/* Improved input styles */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  width: 100%;
  background: var(--bg);
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Improved checkbox styles */
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
}

label.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Better toast notifications */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.toast.gone {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  to {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
}

/* Improved scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== Phase D: WhatsApp-Beating Features ========== */

/* Feature 31: Channels */
.channel-messages {
  max-height: 400px;
  overflow-y: auto;
  margin: 16px 0;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
}

.channel-msg {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--panel);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.channel-msg-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 13px;
}

.channel-msg-time {
  color: var(--ink-soft);
  font-size: 12px;
}

.channel-msg-text {
  font-size: 14px;
  line-height: 1.4;
}

.channel-composer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.channel-composer input {
  flex: 1;
}

/* Feature 33: Polls */
.poll-container {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0;
}

.poll-question {
  font-weight: 600;
  margin-bottom: 12px;
  font-size: 15px;
}

.poll-option {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
  overflow: hidden;
}

.poll-option:hover {
  background: var(--accent-soft);
}

.poll-option.voted {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
}

.poll-option-text {
  flex: 1;
  z-index: 1;
}

.poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.1;
  transition: width 0.3s;
}

.poll-option-votes {
  font-size: 13px;
  color: var(--ink-soft);
  z-index: 1;
  margin-left: 8px;
}

/* Feature 34: Translate */
.translator-original {
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* Feature 35: Payments */
.payment-message {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  padding: 16px;
  border-radius: var(--radius);
  margin: 8px 0;
}

.payment-amount {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.payment-note {
  font-size: 13px;
  opacity: 0.9;
}

/* Feature 36: Product Catalog */
.catalog-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.catalog-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid var(--line);
}

.catalog-info {
  flex: 1;
}

.catalog-info strong {
  display: block;
  margin-bottom: 4px;
}

.catalog-info p {
  margin: 2px 0;
  font-size: 13px;
}

.product-message {
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0;
}

.product-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.product-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 8px;
}

/* Feature 37: Quick Replies */
.quick-replies-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.quick-reply-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--panel);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid var(--line);
}

.quick-reply-info {
  flex: 1;
}

.quick-reply-info strong {
  display: block;
  color: var(--accent);
  margin-bottom: 4px;
}

/* Feature 38: Events */
.event-message {
  background: var(--panel);
  border: 2px solid var(--success);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0;
}

.event-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--success);
}

.event-details {
  font-size: 13px;
  margin-bottom: 4px;
}

.event-attendees {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* Feature 39: Accessibility */
body.high-contrast {
  --bg: #000000;
  --panel: #1a1a1a;
  --ink: #ffffff;
  --ink-soft: #cccccc;
  --line: #333333;
  --accent: #ffff00;
  --accent-dark: #cccc00;
}

body.large-text {
  font-size: 18px;
}

body.large-text .bubble {
  font-size: 17px;
}

body.reduced-motion * {
  animation: none !important;
  transition: none !important;
}

.accessibility-options {
  margin: 16px 0;
}

.accessibility-options label {
  display: block;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: pointer;
}

.accessibility-options label:hover {
  background: var(--accent-soft);
}

.accessibility-options input[type="checkbox"] {
  margin-right: 8px;
}
