:root {
  --bg: #eae6df; --panel: #fff; --panel-2: #f0f2f5; --hover: #f5f6f6; --active: #f0f2f5;
  --border: #e9edef; --text: #111b21; --muted: #667781; --accent: #00a884; --accent-2: #008069;
  --chat-bg: #efeae2; --in: #fff; --out: #d9fdd3; --tick: #53bdeb; --danger: #ea0038;
  --badge: #25d366; --shadow: 0 1px .5px rgba(11,20,26,.13); --quote-bg: rgba(11,20,26,.05);
  --wall: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='%23000' fill-opacity='.025'%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Ccircle cx='50' cy='30' r='1.5'/%3E%3Ccircle cx='30' cy='60' r='2'/%3E%3Ccircle cx='70' cy='70' r='1'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1317; --panel: #111b21; --panel-2: #202c33; --hover: #202c33; --active: #2a3942;
    --border: #222d34; --text: #e9edef; --muted: #8696a0; --accent: #00a884; --accent-2: #00a884;
    --chat-bg: #0b141a; --in: #202c33; --out: #005c4b; --tick: #53bdeb; --danger: #f15c6d;
    --badge: #00a884; --shadow: 0 1px .5px rgba(0,0,0,.3); --quote-bg: rgba(0,0,0,.2);
    --wall: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='%23fff' fill-opacity='.025'%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Ccircle cx='50' cy='30' r='1.5'/%3E%3Ccircle cx='30' cy='60' r='2'/%3E%3Ccircle cx='70' cy='70' r='1'/%3E%3C/g%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14.2px/1.4 "Segoe UI", "Helvetica Neue", Helvetica, "Lucida Grande", Arial, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
h1, h2 { font-weight: 400; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }
.spacer { flex: 1; }

.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 24px; padding: 10px 24px; font-weight: 500;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.icon-btn {
  background: none; border: 0; border-radius: 50%; width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-2); }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* ---- login */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--panel); border-radius: 12px; padding: 36px 32px; width: min(360px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.login-card p { margin: 0; text-align: center; }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card .btn-primary { width: 100%; }

/* ---- app shell */
.app { height: 100%; display: flex; flex-direction: column; }
@media (min-width: 1440px) {
  .app { max-width: 1600px; margin: 0 auto; height: calc(100% - 38px); margin-top: 19px; box-shadow: 0 6px 18px rgba(11,20,26,.05); }
}
.topbar {
  display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--panel-2);
  border-bottom: 1px solid var(--border); min-height: 52px;
}
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 20px; border: 0;
  background: none; white-space: nowrap; color: var(--muted); font-weight: 500;
}
.tab:hover { background: var(--hover); }
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.tab .dot.open { background: #25d366; }
.tab .dot.connecting { background: #f5a623; }
.tab .dot.qr, .tab .dot.logged_out, .tab .dot.idle { background: var(--danger); }
.tab .count { background: var(--badge); color: #fff; border-radius: 10px; font-size: 11.5px; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }

.banner { background: #ffd279; color: #3b2a00; padding: 8px 16px; font-size: 13px; text-align: center; }
.main { flex: 1; min-height: 0; display: flex; background: var(--panel); }

.empty, .link { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; overflow: auto; }
.empty { gap: 8px; align-content: center; }
.empty p { margin: 0 0 12px; }

/* ---- linking */
.link-card { display: flex; gap: 48px; align-items: center; max-width: 900px; text-align: left; flex-wrap: wrap; justify-content: center; }
.link-text { max-width: 420px; }
.link-text h2 { font-size: 26px; margin-bottom: 20px; }
.link-text ol { padding-left: 20px; margin: 0 0 24px; line-height: 2; font-size: 16px; }
.link-alt form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.link-alt input { flex: 1; min-width: 200px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); outline: none; }
.code { font: 600 30px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 4px; margin: 16px 0 4px; color: var(--accent-2); }
.link-actions { display: flex; gap: 20px; margin-top: 24px; }
.qr-box { width: 280px; height: 280px; display: grid; place-items: center; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.qr-box img { width: 264px; height: 264px; image-rendering: pixelated; }
.qr-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #667781; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #e9edef; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- chats */
.chat-ui { flex: 1; display: flex; min-width: 0; }
.sidebar { width: 30%; min-width: 300px; max-width: 480px; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--panel); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 4px 20px; }
.side-head h2 { font-size: 22px; font-weight: 700; }
.search { margin: 6px 12px; display: flex; align-items: center; gap: 12px; background: var(--panel-2); border-radius: 8px; padding: 0 12px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; outline: none; padding: 9px 0; }
.filters { display: flex; gap: 8px; padding: 6px 12px 8px; flex-wrap: wrap; }
.chip { border: 0; border-radius: 16px; padding: 5px 12px; background: var(--panel-2); color: var(--muted); font-size: 13.5px; }
.chip.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-2); }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px; height: 72px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); height: 100%; display: flex; flex-direction: column; justify-content: center; }
.chat-item .row { display: flex; align-items: center; gap: 6px; }
.chat-item .nm { flex: 1; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .tm { font-size: 12px; color: var(--muted); }
.chat-item.unread .tm { color: var(--badge); }
.chat-item .pv { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .badge { background: var(--badge); color: #fff; border-radius: 12px; font-size: 12px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-weight: 600; }
.list-note { padding: 32px 24px; text-align: center; color: var(--muted); }

.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex: none; background: #dfe5e7 center/cover no-repeat;
  display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 18px; overflow: hidden;
}
.convo-head .avatar { width: 40px; height: 40px; font-size: 15px; }

/* ---- conversation */
.convo { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.convo-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px; background: var(--panel-2); border-bottom: 6px solid var(--accent); }
.convo-empty h2 { font-size: 32px; font-weight: 300; }
.convo-main { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.convo-head { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel-2); min-height: 60px; }
.convo-title { min-width: 0; }
.convo-title .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-title .sub { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 12px 7% 8px; background: var(--chat-bg) var(--wall); outline: none; overscroll-behavior: contain; }
.day { display: flex; justify-content: center; margin: 12px 0 8px; position: sticky; top: 4px; z-index: 1; }
.day span { background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); text-transform: uppercase; }
.load-more { text-align: center; color: var(--muted); font-size: 12.5px; padding: 8px; }

.msg { display: flex; margin: 2px 0; position: relative; }
.msg.out { justify-content: flex-end; }
.msg.first { margin-top: 10px; }
.bubble {
  max-width: min(65%, 560px); background: var(--in); border-radius: 8px; padding: 6px 7px 8px 9px; box-shadow: var(--shadow);
  position: relative; word-wrap: break-word; overflow-wrap: anywhere; min-width: 80px;
}
.msg.out .bubble { background: var(--out); }
.msg.first.in .bubble { border-top-left-radius: 0; }
.msg.first.out .bubble { border-top-right-radius: 0; }
.msg.first.in .bubble::before, .msg.first.out .bubble::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px; background: inherit;
}
.msg.first.in .bubble::before { left: -8px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.first.out .bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.sender { font-size: 12.8px; font-weight: 500; margin-bottom: 2px; }
.text { white-space: pre-wrap; font-size: 14.2px; }
.text a { color: #027eb5; }
.text code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.meta { float: right; margin: 6px 0 -5px 10px; font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 3px; position: relative; top: 4px; }
.meta .edited { font-style: italic; }
.tick { display: inline-flex; color: var(--muted); }
.tick.read { color: var(--tick); }
.revoked { font-style: italic; color: var(--muted); }
.quote { background: var(--quote-bg); border-left: 4px solid var(--accent); border-radius: 6px; padding: 5px 8px; margin: 0 0 5px -2px; font-size: 13px; cursor: pointer; }
.quote .qwho { color: var(--accent-2); font-weight: 500; font-size: 12.8px; }
.quote .qtx { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.media { display: block; border-radius: 6px; max-width: 100%; margin: -3px -4px 4px -6px; width: calc(100% + 10px); cursor: pointer; background: var(--quote-bg); min-height: 80px; object-fit: cover; max-height: 420px; }
.bubble.has-media { width: 330px; max-width: 80%; }
video.media { cursor: default; }
.sticker { width: 150px; height: 150px; object-fit: contain; background: none; cursor: default; }
.bubble.sticker-bubble { background: none !important; box-shadow: none; padding: 0; }
.bubble.sticker-bubble::before { display: none; }
.bubble audio { width: 260px; max-width: 100%; display: block; margin: 2px 0 4px; }
.doc { display: flex; align-items: center; gap: 10px; background: var(--quote-bg); border-radius: 6px; padding: 10px; margin-bottom: 4px; color: inherit; text-decoration: none; }
.doc .ic { width: 32px; height: 38px; background: #7f66ff; border-radius: 4px; color: #fff; font-size: 9px; display: grid; place-items: end center; padding-bottom: 4px; font-weight: 700; flex: none; }
.doc .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reactions { position: absolute; bottom: -14px; right: 8px; background: var(--panel); border-radius: 12px; padding: 1px 6px; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.2); z-index: 1; }
.msg.has-react { margin-bottom: 16px; }
.msg-tools { position: absolute; top: 2px; opacity: 0; transition: opacity .1s; }
.msg.in .msg-tools { right: 2px; }
.msg.out .msg-tools { right: 2px; }
.bubble:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-tools button { border: 0; background: var(--panel); border-radius: 50%; width: 24px; height: 24px; color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow); padding: 0; }
.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 30% { filter: brightness(.8); } }

.to-bottom { position: absolute; right: 20px; bottom: 80px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--panel); color: var(--muted); box-shadow: 0 1px 4px rgba(0,0,0,.2); display: grid; place-items: center; z-index: 2; }

.reply-bar { display: flex; align-items: center; gap: 8px; background: var(--panel-2); padding: 8px 12px 0 16px; }
.reply-inner { flex: 1; background: var(--quote-bg); border-left: 4px solid var(--accent); border-radius: 6px; padding: 6px 10px; min-width: 0; }
.reply-who { color: var(--accent-2); font-weight: 500; font-size: 13px; }
.reply-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px; background: var(--panel-2); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: var(--panel); border-radius: 8px; padding: 10px 12px;
  max-height: 140px; line-height: 20px; min-height: 42px;
}
.send { color: var(--accent); }
.drop { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 20%, transparent); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 20px; z-index: 5; pointer-events: none; }

/* ---- floating bits */
.menu { position: fixed; z-index: 50; background: var(--panel); border-radius: 8px; padding: 6px 0; min-width: 180px; box-shadow: 0 2px 12px rgba(11,20,26,.26); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 20px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu .emojis { display: flex; gap: 2px; padding: 4px 8px 6px; border-bottom: 1px solid var(--border); }
.menu .emojis button { width: 36px; height: 36px; padding: 0; font-size: 20px; text-align: center; border-radius: 50%; }
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(11,20,26,.92); display: grid; place-items: center; cursor: zoom-out; }
.viewer img { max-width: 94vw; max-height: 88vh; object-fit: contain; }
.viewer-dl { position: absolute; top: 16px; right: 20px; color: #fff; background: rgba(255,255,255,.15); padding: 8px 14px; border-radius: 20px; text-decoration: none; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #323739; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 70; font-size: 14px; max-width: 90vw; }

/* ---- small screens: list OR conversation */
@media (max-width: 760px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; border-right: 0; }
  .convo { display: none; }
  .chat-ui.in-chat .sidebar { display: none; }
  .chat-ui.in-chat .convo { display: flex; }
  .back { display: inline-flex; margin-left: -8px; }
  .messages { padding: 10px 12px 8px; }
  .bubble { max-width: 85%; }
  .link-card { gap: 24px; }
  .topbar { padding: 6px 4px; }
  .msg-tools { opacity: 1; }
}
.avatar { position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---- chats / calls switch */
.side-tabs { display: flex; gap: 4px; padding: 8px 12px 0; }
.side-tab { flex: 1; border: 0; background: none; padding: 8px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 500; }
.side-tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.side-tab .count { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
.sidebar.calls-mode .search, .sidebar.calls-mode .filters { display: none; }

/* ---- call rows */
.call-item .pv { display: flex; align-items: center; gap: 4px; }
.call-item.missed .nm { color: var(--danger); }
.call-dir { display: inline-flex; }
.call-dir.missed, .call-dir.rejected { color: var(--danger); }
.call-dir.answered, .call-dir.cancelled, .call-dir.failed, .call-dir.ongoing, .call-dir.ringing { color: var(--accent); }
.call-kind { color: var(--muted); display: inline-flex; }

/* ---- incoming call banner (visual only, no sound) */
#call-banners { display: flex; flex-direction: column; }
.call-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--accent-2); color: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
.call-banner .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-banner .who b { font-weight: 600; }
.call-banner button { border: 0; border-radius: 18px; padding: 6px 14px; font-weight: 500; }
.call-banner .decline { background: #ea0038; color: #fff; }
.call-banner .open { background: rgba(255,255,255,.2); color: #fff; }
@keyframes pulse { 50% { filter: brightness(1.12); } }
@media (prefers-reduced-motion: reduce) { .call-banner { animation: none; } }

/* ---- voice recorder */
.recorder { align-items: center; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; margin-left: 6px; }
.rec-time { font-variant-numeric: tabular-nums; min-width: 42px; }
.rec-hint { flex: 1; }

/* ---- call bubble inside a chat */
.bubble.call-bubble { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 8px 10px; }
.call-ic { width: 36px; height: 36px; border-radius: 50%; background: var(--quote-bg); display: grid; place-items: center; color: var(--muted); flex: none; }
.call-ic.missed { color: var(--danger); }
.call-txt { flex: 1; min-width: 0; }
.call-title { font-weight: 500; }
.call-sub { font-size: 12.5px; color: var(--muted); }
.call-bubble .meta { float: none; align-self: flex-end; margin: 0; top: 0; }

/* ---- brute-force warning (stays until an account is relinked) */
.sec-banner { background: var(--danger); color: #fff; padding: 10px 16px; font-size: 13.5px; line-height: 1.45; }
.sec-banner b { font-weight: 600; }

/* ---- settings: side menu + one page */
.me-name { font-size: 13px; margin-right: 2px; }
.overlay { position: fixed; inset: 0; z-index: 55; background: rgba(11,20,26,.5); display: grid; place-items: center; padding: 16px; }
.panel { background: var(--panel); border-radius: 12px; width: min(760px, 100%); height: min(560px, calc(100vh - 32px)); display: flex; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.panel-nav { width: 180px; flex: none; background: var(--panel-2); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; }
.panel-nav-title { font-size: 18px; font-weight: 600; padding: 0 10px 14px; }
.nav-item { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--panel); font-weight: 600; box-shadow: var(--shadow); }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.panel-main { flex: 1; min-width: 0; overflow-y: auto; padding: 18px 24px 20px; position: relative; }
.panel-close { position: absolute; top: 10px; right: 10px; }
.page-head { display: flex; align-items: center; gap: 12px; margin: 0 40px 14px 0; }
.page-head h2 { font-size: 18px; font-weight: 600; flex: 1; }
.small-btn { padding: 7px 16px; font-size: 13.5px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.row-form input { flex: 1; min-width: 150px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); outline: none; }
.row-form input:focus { border-color: var(--accent); }
.users-head { display: flex; justify-content: space-between; padding: 4px 2px 0; }
.user-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.user-line .dot.on { background: #25d366; }
.user-line .uname { font-weight: 500; }
.user-line .you { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.user-line .muted { flex: 1; }
.user-line .usize { font-variant-numeric: tabular-nums; }
.server-line { margin-top: 14px; }
.plain-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 8px; }
.plain-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--border); }
.plain-row .ip { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; }
.list-btn { border: 0; background: none; text-align: left; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.list-btn:hover { color: var(--accent-2); }
.list-btn.danger { color: var(--danger); }
@media (max-width: 760px) {
  .me-name { display: none; }
  .panel { flex-direction: column; height: calc(100vh - 32px); }
  .panel-nav { width: auto; flex-direction: row; padding: 8px; overflow-x: auto; }
  .panel-nav-title { display: none; }
  .panel-main { padding: 14px 14px 18px; }
}
.users-head { display: flex; justify-content: space-between; padding: 4px 2px 0; }
.user-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.user-line .dot.on { background: #25d366; }
.user-line .uname { font-weight: 500; }
.user-line .you { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.user-line .muted { flex: 1; }
.user-line .usize { font-variant-numeric: tabular-nums; }
.sec-dismiss { margin-left: 8px; border: 1px solid rgba(255,255,255,.6); background: none; color: #fff; border-radius: 14px; padding: 2px 12px; font-size: 12.5px; }

/* ---- schedule send */
.sched-card { background: var(--panel); border-radius: 12px; padding: 22px 24px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.sched-card h2 { font-size: 18px; font-weight: 600; }
.sched-text { width: 100%; resize: vertical; min-height: 64px; max-height: 200px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none; }
.sched-text:focus { border-color: var(--accent); }
.sched-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.sched-quick .chip:hover, .sched-quick .chip.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-2); }
.sched-when { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.sched-when input { flex: 1; padding: 9px 12px; outline: none; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); }
.sched-cond { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.sched-cond input { width: 16px; height: 16px; accent-color: var(--accent); }
.info { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font: italic 600 11px/1 Georgia, serif; cursor: help; }
.sched-cond-help { margin: -6px 0 0 24px; }
.sched-actions { display: flex; justify-content: flex-end; gap: 14px; align-items: center; }
/* scheduled = cloud/scalloped edge: a grid of small circles (the bumps along the
   edge) plus an inner rectangle, used as a mask over a light green tint. No tail. */
.msg.sched { margin: 6px 0; }
.msg.first.out.sched .bubble {
  --r: 6px;
  background: color-mix(in srgb, var(--accent) 15%, var(--panel)); border: 0; box-shadow: none; border-radius: 22px !important;
  padding: 13px 18px 14px;
  -webkit-mask: radial-gradient(circle closest-side, #000 96%, #0000) 0 0 / calc(2 * var(--r)) calc(2 * var(--r)) round,
                linear-gradient(#000 0 0) center / calc(100% - 2 * var(--r)) calc(100% - 2 * var(--r)) no-repeat;
          mask: radial-gradient(circle closest-side, #000 96%, #0000) 0 0 / calc(2 * var(--r)) calc(2 * var(--r)) round,
                linear-gradient(#000 0 0) center / calc(100% - 2 * var(--r)) calc(100% - 2 * var(--r)) no-repeat;
}
.msg.first.out.sched .bubble::before { display: none; }
.sched-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.sched-meta .when { flex: 1; }
.sched-meta button { border: 0; background: none; color: var(--muted); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.sched-meta button:hover { background: var(--hover); color: var(--accent-2); }
.sched-meta button.danger:hover { color: var(--danger); }
.sched-note { display: flex; justify-content: center; margin: 8px 0; }
.sched-note span { background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.sched-note button { border: 0; background: none; color: var(--accent-2); font-size: 12.5px; margin-left: 6px; }
.chat-item .sched-ic { color: var(--muted); font-size: 12px; }

/* ---- MCP consent page */
.connect-card { max-width: 420px; text-align: center; }
.connect-card h1 { font-size: 22px; }
.connect-scope { text-align: left; margin: 0; padding-left: 20px; line-height: 1.6; }

/* ---- sub-account mode: same app, only shown chats, no owner-only controls */
.sub-mode #add-acc, .sub-mode #settings-btn, .sub-mode #acc-menu, .sub-mode #tab-calls,
.sub-mode #attach, .sub-mode #mic, .sub-mode #empty-add { display: none !important; }
.sub-banner { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); color: var(--text); }
.meta .via { font-style: italic; margin-right: 4px; }

/* ---- Settings → Sub-accounts / MCP */
.sub-prefix { align-self: center; color: var(--muted); font-size: 14px; }
.sub-row .uname { font-weight: 500; flex: 1; }
.sub-row .tag { font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); }
.sub-row .tag.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-2); }
.sub-row .tag.off { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.row-btns { display: flex; gap: 12px; }
.mcp-url { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 8px; padding: 9px 12px; margin: 6px 0 10px; }
.mcp-url code { flex: 1; font-size: 13.5px; overflow-wrap: anywhere; }
.mcp-how { margin-bottom: 12px; }
.mcp-how summary { cursor: pointer; color: var(--accent-2); }
.mcp-how ol { margin: 8px 0 0; padding-left: 20px; line-height: 1.6; }
.mcp-how code { font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.mcp-pause { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0 6px; cursor: pointer; }
.mcp-pause input { width: 16px; height: 16px; accent-color: var(--danger); }
.mcp-h { margin: 18px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
#mcp-key-form { margin-top: 10px; }
#mcp-key-form select { padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); }
.mcp-key-out { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-top: 8px; }
.mcp-key-out code { display: block; margin: 6px 0; overflow-wrap: anywhere; font-size: 12.5px; }
.mcp-log .plain-row { font-size: 12.5px; padding: 7px 2px; }
.mcp-log .when { color: var(--muted); white-space: nowrap; }
.mcp-log .what { flex: 1; min-width: 0; }
.sub-mode-select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); font-size: 12.5px; }
.sub-row { flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 16px; padding: 2px; }
.seg-btn { border: 0; background: none; border-radius: 14px; padding: 4px 11px; font-size: 12.5px; color: var(--muted); }
.seg-btn.on { background: var(--panel); color: var(--accent-2); font-weight: 600; box-shadow: var(--shadow); }

/* ---- /docs */
body.docs-body { overflow: auto; height: auto; }
.docs { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; line-height: 1.6; font-size: 15px; }
.docs h1 { font-size: 28px; font-weight: 700; margin: 8px 0 12px; }
.docs h2 { font-size: 20px; font-weight: 600; margin: 32px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.docs h3 { font-size: 16px; font-weight: 600; margin: 22px 0 4px; }
.docs code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.docs pre { background: var(--panel-2); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.docs pre code { background: none; padding: 0; }
.docs a { color: var(--accent-2); }
.docs ul, .docs ol { padding-left: 22px; }
.docs-top a { color: var(--accent-2); text-decoration: none; }
.connect-warn { background: rgba(255, 196, 0, 0.12); border: 1px solid rgba(255, 196, 0, 0.45); border-radius: 8px; padding: 8px 10px; text-align: left; }
