/* TeamCommunicate - styles. Mobile first; light and dark themes. */

:root {
  --bg: #e9edf3;
  --panel: #ffffff;
  --panel-2: #f6f8fb;
  --hover: #f1f4f9;
  --chat-bg: #eef2f7;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e3e8ef;
  --brand: #4f46e5;
  --brand-2: #4338ca;
  --brand-ink: #ffffff;
  --brand-soft: #eef0ff;
  --mine: #dfe3ff;
  --mine-ink: #1e1b4b;
  --theirs: #ffffff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --warn-ink: #92400e;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .18);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070b14;
    --panel: #111827;
    --panel-2: #0f1623;
    --hover: #1a2333;
    --chat-bg: #0b1220;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --line: #1f2a3a;
    --brand: #6366f1;
    --brand-2: #818cf8;
    --brand-soft: #1e1b4b;
    --mine: #3730a3;
    --mine-ink: #eef2ff;
    --theirs: #1c2534;
    --ok-soft: #052e16;
    --danger-soft: #450a0a;
    --warn-soft: #422006;
    --warn-ink: #fcd34d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

#app { height: 100vh; height: 100dvh; display: flex; }

/* ---------- icons, avatars, buttons ---------- */
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ic svg { display: block; }

.avatar {
  --size: 44px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: calc(var(--size) * .38);
  letter-spacing: .02em; user-select: none;
}
.avatar.sm { --size: 32px; }
.avatar.lg { --size: 72px; }
.avatar.xl { --size: 104px; }

.logo-badge {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  display: grid; place-items: center; font-size: 19px; box-shadow: var(--shadow);
}
.logo-badge.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 34px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 11px 18px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
  transition: filter .15s, transform .05s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: transparent; color: var(--brand); padding: 8px 10px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.brand { color: var(--brand); }
.icon-btn.muted { color: var(--danger); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
textarea.input { resize: vertical; min-height: 90px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.form-error {
  background: var(--danger-soft); color: var(--danger); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
}

/* ---------- splash & auth ---------- */
.splash { margin: auto; display: grid; justify-items: center; gap: 14px; color: var(--muted); }
.splash-name { font-weight: 700; letter-spacing: .01em; }

.auth-wrap { margin: auto; width: 100%; max-width: 420px; padding: 24px 16px; }
.auth-card { background: var(--panel); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-head { display: grid; justify-items: center; text-align: center; gap: 8px; margin-bottom: 22px; }
.auth-head h1 { margin: 6px 0 0; font-size: 22px; }
.auth-head p { margin: 0; color: var(--muted); }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }

/* ---------- layout ---------- */
.shell {
  display: grid; grid-template-columns: 360px 1fr;
  width: 100%; max-width: 1440px; margin: 0 auto; height: 100%;
  background: var(--panel); box-shadow: var(--shadow);
}
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); position: relative; }

@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; box-shadow: none; }
  .main { display: none; }
  .shell.in-chat .sidebar { display: none; }
  .shell.in-chat .main { display: flex; }
  .shell .back-btn { display: inline-grid !important; }
}
@media (min-width: 1441px) { body { padding: 16px 0; } #app { height: calc(100dvh - 32px); } .shell { border-radius: 16px; overflow: hidden; } }

/* ---------- sidebar ---------- */
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.side-head .title { font-weight: 800; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { margin: 0 12px 8px; position: relative; }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; border: 0; border-radius: 12px; padding: 10px 12px 10px 38px;
  background: var(--panel-2); outline: none;
}
.search input:focus { box-shadow: 0 0 0 2px var(--brand); }

.notice {
  margin: 4px 12px 8px; padding: 10px 12px; border-radius: 12px;
  background: var(--warn-soft); color: var(--warn-ink);
  display: flex; gap: 10px; align-items: center; font-size: 13.5px;
}
.notice .grow { flex: 1; }
.notice button.link { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }
.offline-bar { background: var(--danger); color: #fff; text-align: center; font-size: 13px; padding: 4px; }

.conv-list { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.conv-item {
  display: flex; gap: 12px; align-items: center; width: 100%;
  padding: 10px; border: 0; border-radius: 12px; background: transparent; text-align: left;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--brand-soft); }
.conv-body { flex: 1; min-width: 0; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; }
.conv-name { flex: 1; min-width: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; }
.conv-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.unread .conv-preview { color: var(--text); font-weight: 550; }
.conv-item.unread .conv-time { color: var(--brand); font-weight: 600; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center; flex: none;
}
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px var(--ok-soft); }
.empty-list { text-align: center; color: var(--muted); padding: 40px 24px; }

/* ---------- popover menu ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.menu button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: none; padding: 10px 12px; border-radius: 10px; text-align: left;
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }

/* ---------- chat header ---------- */
.chat-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); min-height: 60px;
}
.back-btn { display: none !important; }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 4px; border-radius: 10px; }
.chat-title:hover { background: var(--hover); }
.chat-title .t1 { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .t2 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title > div { min-width: 0; }

.call-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--ok); color: #fff; font-size: 14px; font-weight: 600;
}
.call-bar .grow { flex: 1; }
.call-bar .btn { background: #fff; color: var(--ok); }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 12px 4% 8px; overscroll-behavior: contain; }
.load-older { text-align: center; padding: 6px; color: var(--muted); font-size: 13px; }
.day-sep { text-align: center; margin: 14px 0 10px; }
.day-sep span, .sys-msg span {
  display: inline-block; padding: 4px 12px; border-radius: 10px;
  background: var(--panel); color: var(--muted); font-size: 12.5px; box-shadow: var(--shadow);
}
.sys-msg { text-align: center; margin: 8px 0; }
.sys-msg span { background: color-mix(in srgb, var(--brand) 12%, var(--panel)); color: var(--text); box-shadow: none; max-width: 90%; }

.msg-row { display: flex; margin-top: 8px; }
.msg-row.cont { margin-top: 2px; }
.msg-row.mine { justify-content: flex-end; }
.bubble {
  position: relative; max-width: min(78%, 560px);
  background: var(--theirs); color: var(--text);
  padding: 7px 10px 6px; border-radius: 16px; border-top-left-radius: 6px;
  box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.msg-row.cont .bubble { border-top-left-radius: 16px; }
.msg-row.mine .bubble { background: var(--mine); color: var(--mine-ink); border-top-left-radius: 16px; border-top-right-radius: 6px; }
.msg-row.mine.cont .bubble { border-top-right-radius: 16px; }
.sender { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.text { white-space: pre-wrap; }
.text a { color: inherit; text-decoration: underline; }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.msg-row.mine .meta { color: color-mix(in srgb, var(--mine-ink) 60%, transparent); }
.meta .ic svg { width: 13px; height: 13px; }
.msg-row.pending .bubble { opacity: .75; }
.msg-row.failed .bubble { outline: 2px solid var(--danger); cursor: pointer; }
.failed-note { font-size: 12px; color: var(--danger); margin-top: 4px; }

.bubble.media { padding: 4px; }
.bubble.media .sender { padding: 2px 6px 0; }
.bubble.media img { display: block; border-radius: 12px; cursor: zoom-in; background: var(--panel-2); object-fit: cover; max-width: 100%; height: auto; }
.bubble.media .meta {
  position: absolute; right: 10px; bottom: 9px; margin: 0; float: none;
  color: #fff !important; background: rgba(0, 0, 0, .45); padding: 1px 7px; border-radius: 8px;
}

.file-card {
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px;
  padding: 8px; margin: 2px 0 4px; border-radius: 12px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  color: inherit; text-decoration: none;
}
.file-card:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.file-icon {
  width: 42px; height: 48px; flex: none; border-radius: 8px;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
}
.file-icon.pdf { background: #dc2626; } .file-icon.doc { background: #2563eb; } .file-icon.xls { background: #16a34a; }
.file-icon.ppt { background: #ea580c; } .file-icon.zip { background: #6b7280; } .file-icon.media { background: #9333ea; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: var(--muted); }
.progress { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }

.call-card { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.call-card .call-ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); flex: none; }
.call-card .call-ic.ended { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); }
.call-card .grow { flex: 1; }
.call-card .t1 { font-weight: 650; }
.call-card .t2 { font-size: 12.5px; color: var(--muted); }

.new-pill {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 84px;
  border: 0; border-radius: 20px; padding: 7px 14px; background: var(--brand); color: #fff;
  font-weight: 600; font-size: 13px; box-shadow: var(--shadow-lg); display: inline-flex; gap: 6px; align-items: center;
}

/* ---------- composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none;
  background: var(--panel-2); border-radius: 22px; padding: 10px 16px;
  max-height: 140px; min-height: 42px; line-height: 1.4;
}
.composer textarea:focus { box-shadow: 0 0 0 2px var(--brand); }
.send-btn { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.send-btn:disabled { opacity: .45; }
.drop-zone {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 18%, transparent); border: 3px dashed var(--brand);
  font-weight: 700; font-size: 18px; color: var(--brand); pointer-events: none;
}

/* ---------- empty main ---------- */
.welcome { margin: auto; text-align: center; max-width: 380px; padding: 24px; color: var(--muted); }
.welcome h2 { color: var(--text); margin: 16px 0 6px; }

/* ---------- modal ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, .5);
  display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 460px; max-height: min(88vh, 760px);
  background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .18s ease-out;
}
.modal.wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 10px 20px; }
.modal-head h3 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; }
@media (max-width: 599px) {
  .backdrop { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); animation: slideup .2s ease-out; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes slideup { from { transform: translateY(40px); opacity: .5; } }

.section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.row-list { display: flex; flex-direction: column; gap: 2px; }
.person {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px;
  border: 0; background: none; width: 100%; text-align: left;
}
button.person:hover, label.person:hover { background: var(--hover); cursor: pointer; }
.person .grow { flex: 1; min-width: 0; }
.person .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; vertical-align: middle; }
.tag.off { background: var(--danger-soft); color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.link-box {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px;
  background: var(--panel-2); border: 1px dashed var(--brand); word-break: break-all; font-size: 13px;
}
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; padding: 4px 10px; border-radius: 20px; }
.status-pill.on { background: var(--ok-soft); color: var(--ok); }
.status-pill.off { background: var(--danger-soft); color: var(--danger); }
.steps { margin: 6px 0 0; padding-left: 20px; }
.steps li { margin: 6px 0; }
.card-soft { background: var(--panel-2); border-radius: 14px; padding: 14px; margin: 10px 0; }
.center { text-align: center; }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; z-index: 90; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: pop .18s ease-out; pointer-events: auto;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- image viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .92); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); color: #fff; }
.viewer-bar .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.viewer-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- calls ---------- */
.call-screen {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  background: linear-gradient(160deg, #1e1b4b, #0f172a 60%); color: #fff;
}
.call-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.call-top .grow { flex: 1; min-width: 0; }
.call-top .t1 { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-top .t2 { font-size: 13px; opacity: .75; }
.call-frame { flex: 1; min-height: 0; }
.call-frame iframe { border: 0; }
.incoming { margin: auto; display: grid; justify-items: center; gap: 14px; text-align: center; padding: 24px; }
.incoming .who { font-size: 24px; font-weight: 700; }
.incoming .what { opacity: .8; }
.pulse { border-radius: 50%; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, .6); } 70% { box-shadow: 0 0 0 28px rgba(99, 102, 241, 0); } 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); } }
.call-actions { display: flex; gap: 48px; margin-top: 28px; }
.call-actions .col { display: grid; justify-items: center; gap: 8px; font-size: 14px; }
.round { width: 66px; height: 66px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-lg); }
.round.green { background: #16a34a; }
.round.red { background: #dc2626; }
.round.red .ic { transform: rotate(135deg); }
.call-loading { margin: auto; text-align: center; opacity: .85; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* on/off switch (message sound) */
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch-row .small { color: var(--muted); margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- v1.1: reply, edit, delete, forward, ticks, typing, mute, voice, search ---------- */
:root { --tick-read: #0ea5e9; }
@media (prefers-color-scheme: dark) { :root { --tick-read: #38bdf8; } }

/* message options button (computers) */
.msg-act {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: inherit; color: var(--muted);
  opacity: 0; transition: opacity .12s; cursor: pointer; box-shadow: -6px 0 8px -2px var(--theirs);
}
.msg-row.mine .msg-act { box-shadow: -6px 0 8px -2px var(--mine); color: color-mix(in srgb, var(--mine-ink) 60%, transparent); }
.bubble:hover .msg-act, .msg-act:focus-visible { opacity: 1; }
.bubble.media .msg-act { top: 8px; right: 8px; background: rgba(0, 0, 0, .45); color: #fff; box-shadow: none; }
@media (hover: none) {
  .msg-act { display: none; }
  .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
.messages { touch-action: pan-y; }
.msg-row.flash .bubble { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--brand); } 100% { box-shadow: var(--shadow); } }

/* quoted message inside a reply */
.quote {
  border-left: 4px solid var(--brand); border-radius: 8px; padding: 5px 9px; margin: 2px 0 5px;
  background: color-mix(in srgb, var(--text) 6%, transparent); cursor: pointer; min-width: 120px;
}
.bubble.media .quote { margin: 2px 2px 6px; }
.quote:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.q-name { font-size: 12.5px; font-weight: 700; }
.q-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.msg-row.mine .q-text { color: color-mix(in srgb, var(--mine-ink) 70%, transparent); }

.fwd { display: flex; align-items: center; gap: 4px; font-size: 12px; font-style: italic; color: var(--muted); margin-bottom: 2px; }
.msg-row.mine .fwd { color: color-mix(in srgb, var(--mine-ink) 65%, transparent); }
.bubble.media .fwd { padding: 2px 6px 0; }
.deleted-text { font-style: italic; color: var(--muted); display: block; }
.deleted-text > .ic { vertical-align: -3px; margin-right: 5px; }
.msg-row.mine .deleted-text { color: color-mix(in srgb, var(--mine-ink) 65%, transparent); }
.edited { font-style: italic; }

/* ✓ / ✓✓ ticks */
.tick { display: inline-flex; margin-left: 1px; }
.tick svg { width: 16px !important; height: 16px !important; }
.tick.read { color: var(--tick-read); }
.bubble.media .tick.read { color: #7dd3fc; }

/* reply / edit bar above the message box */
.composer-wrap { background: var(--panel); border-top: 1px solid var(--line); }
.composer-wrap .composer { border-top: 0; }
.compose-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0 14px; }
.cb-ic { color: var(--brand); display: grid; }
.cb-body { flex: 1; min-width: 0; border-left: 4px solid var(--brand); background: var(--panel-2); border-radius: 8px; padding: 5px 10px; }
.cb-title { font-size: 12.5px; font-weight: 700; color: var(--brand); }
.cb-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* voice messages */
.send-btn.mic { background: var(--brand); }
.recorder { align-items: center; }
.rec-info { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 8px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-label { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.danger-ic { color: var(--danger); }
.voice-note { display: flex; align-items: center; gap: 10px; min-width: 230px; max-width: 300px; padding: 4px 2px 2px; }
.vn-play {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand); color: #fff; cursor: pointer;
}
.vn-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.vn-track { position: relative; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--text) 15%, transparent); cursor: pointer; }
.vn-track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--brand); }
.vn-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.msg-row.mine .vn-time { color: color-mix(in srgb, var(--mine-ink) 65%, transparent); }
.vn-mic { color: var(--muted); display: grid; }

/* typing + mute */
.conv-preview.typing, .chat-title .t2.typing { color: var(--ok); font-weight: 600; font-style: italic; }
.muted-ic { color: var(--muted); display: inline-grid; flex: none; }
.badge.quiet { background: var(--muted); }
.head-muted { color: var(--muted); margin-left: 6px; vertical-align: -2px; display: inline-flex; }
.avatar.soft { background: var(--panel-2) !important; color: var(--text); }
.mute-row { margin: 6px 0; border: 1px solid var(--line); }
.mute-row .link { font-weight: 600; color: var(--brand); }

/* forward window */
.fwd-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-actions { position: sticky; bottom: -20px; background: var(--panel); padding: 12px 0 4px; margin-top: 8px; }

/* message search results */
.list-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 12px 4px; }
.empty-list.small { padding: 14px 24px; font-size: 14px; }
.hit-text mark { background: color-mix(in srgb, var(--brand) 25%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
