:root {
  --bg: #f0f2f5; --panel: #ffffff; --head: #f0f2f5; --line: #e9edef; --hover: #f5f6f6; --active: #f0f2f5;
  --text: #111b21; --muted: #667781; --accent: #00a884; --accent-2: #008069; --accent-soft: #d9fdd3;
  --chat-bg: #efeae2; --in: #ffffff; --out: #d9fdd3; --sys: #ffeecd; --day: #ffffffe6; --quote: #0000000d;
  --danger: #ea0038; --read: #53bdeb; --shadow: 0 1px .5px rgba(11,20,26,.13); --modal: rgba(11,20,26,.45);
  --input: #ffffff; --chip: #f0f2f5; --chip-on: #d9fdd3; --chip-on-text: #008069;
  --radius: 8px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1317; --panel: #111b21; --head: #202c33; --line: #222d34; --hover: #202c33; --active: #2a3942;
    --text: #e9edef; --muted: #8696a0; --accent: #00a884; --accent-2: #00a884; --accent-soft: #005c4b;
    --chat-bg: #0b141a; --in: #202c33; --out: #005c4b; --sys: #182229; --day: #182229; --quote: #ffffff12;
    --input: #2a3942; --chip: #202c33; --chip-on: #0a332c; --chip-on-text: #00a884; --modal: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1317; --panel: #111b21; --head: #202c33; --line: #222d34; --hover: #202c33; --active: #2a3942;
  --text: #e9edef; --muted: #8696a0; --accent: #00a884; --accent-2: #00a884; --accent-soft: #005c4b;
  --chat-bg: #0b141a; --in: #202c33; --out: #005c4b; --sys: #182229; --day: #182229; --quote: #ffffff12;
  --input: #2a3942; --chip: #202c33; --chip-on: #0a332c; --chip-on-text: #00a884; --modal: rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: start; }
a { color: var(--accent-2); }
input, textarea, select { font: inherit; color: inherit; }
img, video { display: block; }
.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-dots { stroke-width: 3.2; }
.dim { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.big { font-size: 26px; }
[dir="rtl"] .ic.flipx, [dir="rtl"] .back-btn .ic, [dir="rtl"] .panel-head > .icon-btn:first-child .ic, [dir="rtl"] .viewer-head > .icon-btn:first-child .ic { transform: scaleX(-1); }

/* ---------- controles */
.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--input); outline: none; margin: 6px 0; resize: vertical;
}
.input:focus { border-color: var(--accent); }
.input.sm { width: auto; max-width: 160px; padding: 6px 8px; margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 22px; border-radius: 24px; font-weight: 600; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; margin-top: 12px; }
.btn-text { color: var(--accent-2); font-weight: 600; padding: 8px 12px; border-radius: 20px; }
.btn-text:hover { background: var(--hover); }
.btn-text.danger, .danger { color: var(--danger); }
.btn-text.sm { padding: 4px 8px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.danger { color: var(--danger); }
.switch { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--muted); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
[dir="rtl"] .switch:checked::after { transform: translateX(-16px); }
.chips { display: flex; gap: 8px; padding: 6px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; padding: 6px 0; }
.chip { padding: 6px 12px; border-radius: 16px; background: var(--chip); color: var(--muted); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--chip-on); color: var(--chip-on-text); font-weight: 600; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 20px; }

/* ---------- avatares */
.avatar {
  border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; overflow: visible;
  color: #fff; font-weight: 600; position: relative; user-select: none; background: #6a7175;
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar.accent { background: var(--accent); }
.avatar.announce { background: var(--accent-2); color: #fff; }
.avatar.flag-av { background: var(--chip); font-size: 24px; }
.avatar .flag { position: absolute; bottom: -2px; inset-inline-end: -2px; font-size: 14px; line-height: 1; }

/* ---------- acceso */
body.auth { overflow: auto; }
.auth-wrap { flex: 1; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(180deg, var(--accent-2) 0 200px, var(--bg) 200px); }
.auth-col { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.install-card { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 16px; padding: 14px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.12); text-align: start; flex-wrap: wrap; }
.install-card img { border-radius: 12px; flex: none; }
.install-txt { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.install-txt small { color: var(--muted); }
.install-card .btn { width: 100%; }
.banner.install-banner { background: var(--accent); color: #fff; justify-content: center; font-size: 16px; padding: 12px; }
.install-steps { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; font-size: 16px; }
.install-steps img { border-radius: 14px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 16px; padding: 28px 24px; box-shadow: 0 6px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; align-items: stretch; text-align: center; }
.auth-card h1 { margin: 8px 0 2px; font-size: 26px; }
.auth-card .btn { margin: 12px 0 6px; }
.auth-logo img { width: 84px; height: 84px; margin: 0 auto; border-radius: 22px; }
.auth-err { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ---------- distribucion */
#app { height: 100%; display: flex; }
#side { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--panel); border-inline-end: 1px solid var(--line); min-width: 0; }
#main { display: none; flex: 1; height: 100%; min-width: 0; background: var(--chat-bg); }
#drawer { display: none; }
body.in-chat #side { display: none; }
body.in-chat #main { display: flex; }
#drawer.show { display: flex; position: fixed; inset: 0; z-index: 30; background: var(--panel); }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  #side { width: 32%; min-width: 320px; max-width: 440px; display: flex !important; }
  #main { display: flex; }
}
@media (min-width: 1100px) and (hover: hover) and (pointer: fine) {
  #drawer.show { position: static; width: 30%; max-width: 420px; min-width: 320px; border-inline-start: 1px solid var(--line); }
}

.side-head { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-t)) 12px 6px 16px; }
.side-title { font-size: 22px; margin: 0; font-weight: 700; color: var(--accent-2); }
.head-btns { display: flex; align-items: center; gap: 2px; }
.me-btn { width: 40px; }
.conn { display: none; background: #ffd279; color: #3b2a00; font-size: 13px; text-align: center; padding: 4px; }
.conn.show { display: block; }
.side-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
#side { position: relative; }
.fab-new { display: none; position: absolute; inset-inline-end: 16px; bottom: calc(76px + var(--safe-b)); width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 5; }
@media (hover: none), (pointer: coarse) { .fab-new { display: flex; } }
.search-in { margin: 4px 12px; width: calc(100% - 24px); border-radius: 20px; background: var(--chip); border-color: transparent; padding: 8px 16px; }
.tabs { display: flex; border-top: 1px solid var(--line); padding-bottom: var(--safe-b); background: var(--panel); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; color: var(--muted); font-size: 12px; }
.tab-ic { position: relative; padding: 4px 18px; border-radius: 16px; display: flex; }
.tab.on { color: var(--text); font-weight: 600; }
.tab.on .tab-ic { background: var(--chip-on); color: var(--chip-on-text); }
.badge { position: absolute; top: -2px; inset-inline-end: 6px; background: var(--accent); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; font-weight: 700; }
.banner { display: flex; align-items: center; gap: 10px; margin: 6px 12px; padding: 10px 12px; border-radius: 10px; background: var(--chip-on); color: var(--chip-on-text); width: calc(100% - 24px); font-size: 14px; }
.empty-main { margin: auto; text-align: center; padding: 24px; max-width: 460px; }
.empty-main img { margin: 0 auto 8px; border-radius: 24px; opacity: .9; }
.empty-main h2 { font-weight: 400; font-size: 28px; margin: 8px 0; }

/* ---------- listas */
.list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 14px; min-height: 60px; cursor: pointer; text-decoration: none; color: inherit; }
.list-row:hover { background: var(--hover); }
.list-row.active { background: var(--active); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.chat-row .row-main, .comm-row .row-main { border-bottom: 1px solid var(--line); align-self: stretch; padding: 4px 0; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-title { flex: 1; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-title.missed { color: var(--danger); }
.row-time { font-size: 12px; color: var(--muted); flex: none; }
.row-time.hot { color: var(--accent); font-weight: 600; }
.row-sub { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; }
.sub-wrap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-wrap .tick { vertical-align: -1px; margin-inline-end: 2px; }
.row-icons { display: flex; align-items: center; gap: 4px; flex: none; }
.unread { background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; }
.unread.muted { background: var(--muted); }
.typing-txt { color: var(--accent) !important; font-weight: 500; }
.list-sec { padding: 14px 16px 6px; color: var(--accent-2); font-size: 14px; font-weight: 600; }
.empty-list { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty-list .btn { margin-top: 10px; }
.archived-row { min-height: 48px; color: var(--accent-2); font-weight: 600; }
.archived-row span:first-of-type { flex: 1; }
.count { color: var(--accent); font-size: 13px; }
.opt-row { min-height: 54px; }
.opt-row:has(> select) .row-sub { white-space: normal; } /* descripciones de ajustes con desplegable: sin cortar */
.opt-row > .ic { color: var(--muted); }
.opt-row.danger, .opt-row.danger .ic { color: var(--danger); }
.join-pill { background: var(--chip-on); color: var(--chip-on-text); font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 14px; flex: none; }
.role-tag { font-size: 12px; color: var(--accent-2); background: var(--chip-on); padding: 2px 8px; border-radius: 6px; flex: none; }
.accent-ic { color: var(--accent); }
.comm-av { border-radius: 14px !important; font-size: 20px; }
.row-tap { display: flex; }
.ic.missed { color: var(--danger); }
.ic.ok { color: var(--accent); }

/* ---------- ticks */
.tick { display: inline-flex; color: var(--muted); vertical-align: middle; }
.tick.read { color: var(--read); }
.tick.fail { color: var(--danger); }
.msg .tick { margin-inline-start: 3px; }

/* ---------- modales y hojas */
.modal-back { position: fixed; inset: 0; z-index: 100; background: var(--modal); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .15s; padding: 16px; }
.modal-back.show { opacity: 1; }
.modal-box { max-width: 100%; max-height: 100%; display: flex; }
.modal-back.sheet { align-items: flex-end; padding: 0; }
.modal-back.sheet .modal-box { width: 100%; max-width: 520px; transform: translateY(30px); transition: transform .18s; }
.modal-back.sheet.show .modal-box { transform: none; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { .modal-back.sheet { align-items: center; padding: 16px; } }
.modal-back.full { padding: 0; }
.modal-back.full .modal-box { width: 100%; height: 100%; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { .modal-back.full .modal-box:not(.dark) { width: 480px; height: min(90vh, 760px); border-radius: 12px; overflow: hidden; } }
.modal-box.dark { background: #000; color: #fff; width: 100%; height: 100%; }
.dialog { background: var(--panel); border-radius: 12px; padding: 20px 20px 10px; width: min(420px, 100vw - 32px); max-height: 85vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialog h3 { margin: 0 0 10px; font-size: 18px; }
.dialog p { margin: 0 0 12px; }
.dialog-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.dialog-btns.col { flex-direction: column; align-items: flex-end; }
.sheet-list { background: var(--panel); border-radius: 16px 16px 0 0; width: 100%; padding: 8px 0 calc(8px + var(--safe-b)); max-height: 85vh; overflow-y: auto; }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { .sheet-list { border-radius: 12px; } }
.sheet-title { padding: 10px 20px; font-weight: 600; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-item { display: flex; align-items: center; gap: 16px; width: 100%; padding: 12px 20px; }
.sheet-item:hover { background: var(--hover); }
.sheet-item .ic { color: var(--muted); }
.sheet-item.danger, .sheet-item.danger .ic { color: var(--danger); }
.panel { background: var(--panel); width: 100%; height: 100%; display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 8px 8px; background: var(--head); min-height: 56px; }
.panel-head h2 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .input { margin: 0; }
.panel-body { flex: 1; overflow-y: auto; padding: 8px 0; }
.panel-body > .input { margin: 6px 12px; width: calc(100% - 24px); }
.panel-body > .btn.block { margin: 12px; width: calc(100% - 24px); }
.panel-foot { padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
.panel-foot .btn.block { margin: 0; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.pick-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--chip); border-radius: 16px; padding: 3px 8px 3px 3px; font-size: 14px; }
.check-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translate(-50%, 20px); background: #323739; color: #fff; padding: 10px 18px; border-radius: 20px; z-index: 300; font-size: 14px; opacity: 0; transition: all .2s; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- chat */
.chat { display: flex; flex-direction: column; width: 100%; height: 100%; min-width: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 6px 6px; background: var(--head); min-height: 58px; z-index: 2; }
.back-btn { color: var(--text); }
@media (min-width: 900px) and (hover: hover) and (pointer: fine) { .back-btn { display: none !important; } .chat-head { padding-inline-start: 14px; } }
.head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.head-txt { min-width: 0; }
.head-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-bar { display: none; align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1; }
.pinned-bar.show { display: flex; }
.pinned-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.pinned-txt b { color: var(--accent-2); font-weight: 600; }
.pinned-txt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.msgs-wrap { flex: 1; position: relative; min-height: 0; }
.msgs {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 4% 8px; overscroll-behavior: contain;
  background-color: var(--chat-bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(127,127,127,.09) 1px, transparent 0);
  background-size: 22px 22px;
}
@media (min-width: 1200px) and (hover: hover) and (pointer: fine) { .msgs { padding-inline: 7%; } }
.fab-down { position: absolute; bottom: 14px; inset-inline-end: 16px; width: 42px; height: 42px; border-radius: 50%; background: var(--panel); box-shadow: 0 2px 6px rgba(0,0,0,.2); display: none; align-items: center; justify-content: center; color: var(--muted); z-index: 3; }
.fab-down.show { display: flex; }
.fab-badge:not(:empty) { position: absolute; top: -6px; inset-inline-end: -4px; background: var(--accent); color: #fff; font-size: 11px; border-radius: 10px; min-width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.chat-start { text-align: center; margin: 6px auto 12px; max-width: 480px; }
.chat-start span { display: inline-block; background: var(--sys); color: var(--muted); font-size: 12.5px; padding: 6px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.day-sep, .sys-msg, .unread-sep { text-align: center; margin: 10px 0; }
.day-sep span, .sys-msg span { display: inline-block; background: var(--day); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.day-sep { position: sticky; top: 0; z-index: 1; }
.sys-msg span { background: var(--sys); }
.unread-sep span { display: block; background: rgba(127,127,127,.15); color: var(--text); font-size: 13px; padding: 5px; }

.msg { display: flex; align-items: flex-end; gap: 6px; margin-top: 8px; position: relative; }
.msg.cont { margin-top: 2px; }
.msg.out { justify-content: flex-end; }
.msg-col { display: flex; flex-direction: column; max-width: min(78%, 620px); min-width: 0; }
.msg.out .msg-col { align-items: flex-end; }
.msg.in .msg-col { align-items: flex-start; }
.av-space, .msg-av { width: 32px; flex: none; align-self: flex-start; }
.bubble {
  position: relative; background: var(--in); border-radius: 8px; padding: 6px 7px 8px 9px; box-shadow: var(--shadow);
  min-width: 80px; max-width: 100%; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--out); }
.msg.in:not(.cont) .bubble { border-start-start-radius: 0; }
.msg.out:not(.cont) .bubble { border-start-end-radius: 0; }
.msg.mentioned .bubble { box-shadow: 0 0 0 2px var(--accent) inset, var(--shadow); }
.msg.flash .bubble { animation: flash 1.5s; }
@keyframes flash { 0%, 60% { filter: brightness(.82); } }
.sender-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 2px; max-width: 100%; }
.sender-name { flex-wrap: wrap; row-gap: 2px; text-align: start; }
/* insignias de staff y cargos (staffBadges): el color se mezcla con el del texto para leerse en claro y oscuro */
.rank-chip { --c: #3b82f6; display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-inline-start: 4px; font-size: 10.5px; font-weight: 700; line-height: 16px; padding: 0 6px; border-radius: 8px; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; flex: none;
  color: color-mix(in srgb, var(--c) 72%, var(--text)); background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.sender-name .rank-chip { margin-inline-start: 0; }
.rank-chip .ic { width: 11px; height: 11px; stroke-width: 2.4; }
.b-owner { --c: #d4a017; } .b-owner .ic { fill: currentColor; }
.b-admin { --c: #e5484d; } .b-cadmin { --c: #2fa36b; } .b-mod { --c: #3b82f6; }
.badge-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 4px 0; }
.badge-row .rank-chip { margin: 0; font-size: 12px; line-height: 20px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; }
.swatch.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.bc-list { max-height: 34vh; overflow-y: auto; }
.rank-help { padding: 4px 16px 10px; }
.rank-help .sec-title { padding-inline: 0; }
.row-title:has(> .rank-chip) { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; white-space: normal; } /* nombre + insignias sin cortar */
.row-title > .rank-chip { margin: 0; }
.rank-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); margin: 6px 0; }
.rank-line .rank-chip { margin: 0; }
.txt { white-space: normal; padding-inline-end: 4px; }
.txt::after { content: ""; display: inline-block; width: 64px; } /* espacio para la hora */
.msg.out .txt::after { width: 80px; }
.txt.big-emoji { font-size: 44px; line-height: 1.15; }
.txt.clamp { max-height: 22em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.txt code { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; background: var(--quote); padding: 1px 4px; border-radius: 4px; white-space: pre-wrap; }
.mention { color: var(--accent-2); font-weight: 500; cursor: pointer; }
.read-more { color: var(--accent-2); font-size: 14px; font-weight: 600; margin-top: 2px; }
.meta { float: inline-end; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); margin: 6px 0 -4px 6px; line-height: 1; white-space: nowrap; position: relative; top: 2px; }
.bubble > .meta { position: absolute; bottom: 5px; inset-inline-end: 7px; margin: 0; top: auto; }
.bubble:has(> .media-box:last-of-type) > .meta { color: #fff; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 10px; bottom: 10px; inset-inline-end: 10px; }
.bubble:has(> .media-box:last-of-type) > .meta .tick { color: #fff; }
.bubble:has(> .media-box:last-of-type) > .meta .tick.read { color: var(--read); }
.edited { font-style: italic; }
.star-ic { fill: currentColor; stroke: none; }
.deleted .del-txt { color: var(--muted); font-style: italic; display: inline-flex; align-items: center; gap: 4px; padding-inline-end: 70px; }
.fwd { color: var(--muted); font-size: 12.5px; font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.retry { color: var(--danger); font-size: 13px; font-weight: 600; display: block; margin-top: 4px; }
.msg-more { opacity: 0; position: absolute; top: 2px; width: 26px; height: 26px; border-radius: 50%; background: var(--panel); display: flex; align-items: center; justify-content: center; color: var(--muted); box-shadow: var(--shadow); transition: opacity .1s; }
.msg.out .msg-more { inset-inline-end: calc(min(78%, 620px) + 4px); position: static; order: -1; align-self: center; }
.msg.in .msg-more { position: static; align-self: center; }
.msg:hover .msg-more { opacity: 1; }
.quote {
  display: flex; gap: 6px; background: var(--quote); border-inline-start: 4px solid; border-radius: 6px; padding: 5px 8px; margin: 2px 0 5px; width: 100%; min-width: 0; overflow: hidden;
}
.quote-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.quote-txt b { font-size: 13px; }
.quote-txt span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.quote-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; flex: none; }
.link-card { display: flex; flex-direction: column; background: var(--quote); border-radius: 6px; overflow: hidden; margin: 4px 0 2px; text-decoration: none; color: inherit; max-width: 360px; }
.link-card img { width: 100%; max-height: 180px; object-fit: cover; }
.link-txt { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.link-txt b { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-txt span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-txt small { color: var(--muted); }
.media-box { position: relative; margin: -2px -3px 4px; border-radius: 6px; overflow: hidden; cursor: pointer; max-width: 330px; background: var(--quote); }
.media-img { width: 100%; max-width: 330px; min-width: 160px; max-height: 360px; object-fit: cover; }
.bubble:has(> .media-box) { padding: 3px 3px 6px; }
.bubble:has(> .media-box) > .txt { padding: 2px 6px 0; }
.bubble:has(> .media-box) > .sender-name, .bubble:has(> .media-box) > .fwd, .bubble:has(> .media-box) > .quote { margin-inline: 4px; width: auto; }
.play-ov { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center; }
.play-ov .ic { fill: #fff; margin-inline-start: 3px; }
.dur { position: absolute; bottom: 8px; inset-inline-start: 8px; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000; display: flex; align-items: center; gap: 3px; }
.up-prog { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); }
.voice .up-prog, .file-card .up-prog { position: relative; inset: auto; background: none; width: 44px; height: 44px; }
.ring { position: absolute; width: 48px; height: 48px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,.25) 0); -webkit-mask: radial-gradient(circle, transparent 19px, #000 20px); mask: radial-gradient(circle, transparent 19px, #000 20px); }
.up-prog .icon-btn { color: #fff; position: relative; }
.voice .up-prog .icon-btn, .file-card .up-prog .icon-btn { color: var(--muted); }
.file-card { display: flex; align-items: center; gap: 10px; background: var(--quote); border-radius: 6px; padding: 8px 10px; margin-bottom: 4px; text-decoration: none; color: inherit; min-width: 220px; max-width: 330px; }
.file-ic { position: relative; color: var(--muted); display: flex; flex-direction: column; align-items: center; }
.file-ic small { font-size: 8px; font-weight: 700; position: absolute; bottom: 4px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta small { color: var(--muted); font-size: 12px; }
.file-dl { color: var(--muted); border: 1.5px solid var(--muted); border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; flex: none; }
.audio-box { min-width: 240px; padding-bottom: 14px; }
.audio-box audio { width: 100%; height: 40px; margin-top: 4px; }
.voice { display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 320px; padding: 2px 0 12px; }
.voice .avatar { position: relative; }
.v-mic { position: absolute; bottom: -2px; inset-inline-end: -4px; color: var(--accent); background: var(--in); border-radius: 50%; padding: 2px; display: flex; }
.v-play { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.v-play .ic { fill: currentColor; }
.v-main { flex: 1; min-width: 0; position: relative; }
.v-bars { display: flex; align-items: center; gap: 1px; height: 30px; cursor: pointer; overflow: hidden; }
.v-bars i { flex: 1; min-width: 1px; max-width: 4px; background: var(--muted); opacity: .55; border-radius: 2px; }
.v-bars i.on { background: var(--accent); opacity: 1; }
.v-time { position: absolute; bottom: -14px; inset-inline-start: 0; font-size: 11px; color: var(--muted); }
.v-speed { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--quote); border-radius: 10px; padding: 2px 6px; flex: none; }
.reactions { display: inline-flex; align-items: center; gap: 1px; background: var(--panel); border-radius: 12px; padding: 1px 6px; margin-top: -6px; font-size: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.2); z-index: 1; border: 1px solid var(--line); margin-inline: 8px; }
.reactions.mine { border-color: var(--accent); }
.reactions small { color: var(--muted); font-size: 12px; margin-inline-start: 3px; }

/* ---------- compositor */
.composer-wrap { position: relative; background: var(--head); padding-bottom: var(--safe-b); z-index: 2; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px; }
.compose-box { flex: 1; display: flex; align-items: flex-end; background: var(--input); border-radius: 24px; min-height: 46px; padding: 3px 4px; min-width: 0; }
.compose-in { flex: 1; border: 0; outline: none; background: transparent; resize: none; padding: 10px 4px; max-height: 140px; line-height: 1.35; min-width: 0; }
.send-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.send-btn .ic { width: 22px; height: 22px; }
[dir="rtl"] .send-btn:not(.mic) .ic { transform: scaleX(-1); }
.composer-note { text-align: center; padding: 14px 16px; color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.compose-top:not(:empty) { padding: 6px 8px 0; }
.compose-quote { display: flex; align-items: center; gap: 6px; background: var(--quote); border-inline-start: 4px solid; border-radius: 6px; padding: 6px 4px 6px 10px; }
.compose-quote b { color: var(--accent-2); }
.emoji-panel { display: none; height: 260px; border-top: 1px solid var(--line); background: var(--panel); }
.emoji-panel.show { display: block; }
.emoji-wrap { display: flex; flex-direction: column; height: 100%; }
.emoji-tabs { display: flex; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.emoji-tabs button { font-size: 20px; padding: 4px 8px; border-radius: 8px; opacity: .6; }
.emoji-tabs button.on { opacity: 1; background: var(--chip); }
.emoji-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); padding: 6px; align-content: start; }
.emoji-grid button { font-size: 26px; height: 42px; border-radius: 8px; text-align: center; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-sheet { background: var(--panel); width: 100%; height: 340px; border-radius: 16px 16px 0 0; overflow: hidden; }
/* stickers y GIFs */
.emoji-panel:has(> .cp-wrap) { height: 320px; }
.cp-wrap { display: flex; flex-direction: column; height: 100%; }
.cp-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cp-body > * { flex: 1; min-height: 0; }
.cp-tabs { display: flex; justify-content: center; gap: 6px; padding: 4px; border-top: 1px solid var(--line); }
.cp-tabs button { padding: 5px 14px; border-radius: 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cp-tabs button.on { background: var(--chip-on); color: var(--chip-on-text); }
.stk-pane, .gif-pane { overflow-y: auto; padding: 6px 8px; }
.stk-bar { display: flex; gap: 6px; padding: 2px 0 6px; }
.stk-bar .chip { display: inline-flex; align-items: center; gap: 4px; }
.stk-title { font-size: 12px; font-weight: 600; color: var(--muted); margin: 6px 2px 4px; text-transform: uppercase; }
.stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 4px; }
.stk-item { aspect-ratio: 1; border-radius: 8px; padding: 4px; }
.stk-item:hover { background: var(--hover); }
.stk-item img { width: 100%; height: 100%; object-fit: contain; }
.stk-preview { display: flex; justify-content: center; padding: 12px; }
.stk-preview img { width: 160px; height: 160px; object-fit: contain; }
.bubble:has(> .sticker-img) { background: none; box-shadow: none; padding: 0; min-width: 0; }
.sticker-img { display: block; width: 150px; height: 150px; object-fit: contain; cursor: pointer; }
.bubble:has(> .sticker-img) > .meta { color: #fff; background: rgba(0,0,0,.4); padding: 2px 6px; border-radius: 10px; bottom: 4px; }
.bubble:has(> .sticker-img) > .meta .tick { color: #fff; }
.bubble:has(> .sticker-img) > .meta .tick.read { color: var(--read); }
.bubble:has(> .sticker-img) > .sender-name, .bubble:has(> .sticker-img) > .fwd, .bubble:has(> .sticker-img) > .quote { background: var(--in); border-radius: 8px; padding: 2px 8px; margin-bottom: 4px; }
.gif-badge { position: absolute; top: 8px; inset-inline-start: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; pointer-events: none; }
.gif-search { width: 100%; margin-bottom: 6px; }
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
.gif-item { position: relative; height: 96px; border-radius: 6px; overflow: hidden; background: var(--chip); }
.gif-item img, .gif-item video { width: 100%; height: 100%; object-fit: cover; }
.gif-item.busy { opacity: .45; pointer-events: none; }
.gif-note { font-size: 13px; color: var(--muted); padding: 6px 2px; grid-column: 1 / -1; }
.gif-attr { font-size: 10px; color: var(--muted); text-align: end; padding: 4px 2px 0; }
.mention-wrap { position: absolute; bottom: 100%; left: 0; right: 0; }
.mention-box { background: var(--panel); max-height: 240px; overflow-y: auto; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0,0,0,.08); }
.mention-box .list-row { min-height: 48px; }
.mention-box .sel { background: var(--active); }
.recording { align-items: center; padding: 8px 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; min-width: 44px; }
.rec-bars { flex: 1; display: flex; align-items: center; gap: 2px; height: 36px; overflow: hidden; justify-content: flex-end; }
.rec-bars i { width: 3px; background: var(--muted); border-radius: 2px; flex: none; }
.react-row { display: flex; justify-content: space-around; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); }
.react-btn { font-size: 28px; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: transform .1s; }
.react-btn:hover { background: var(--hover); transform: scale(1.15); }
.react-btn.plus { color: var(--muted); background: var(--chip); }

/* ---------- enviar archivos */
.send-panel .panel-body { background: var(--chat-bg); }
.send-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 8px; }
.send-item { background: var(--panel); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; align-items: center; }
.send-item img, .send-item video { width: 100%; height: 140px; object-fit: cover; }
.send-item .file-ic { height: 140px; justify-content: center; }
.send-item small { padding: 4px 6px; font-size: 11px; color: var(--muted); width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-foot { display: flex; gap: 8px; align-items: center; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--head); }
.send-foot .input { margin: 0; border-radius: 22px; }

/* ---------- visor */
.viewer, .st-viewer, .st-editor, .call-screen { position: relative; width: 100%; height: 100%; background: #000; color: #fff; display: flex; flex-direction: column; overflow: hidden; }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 8px 8px; z-index: 3; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.viewer-head .icon-btn { color: #fff; }
.viewer-head .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-title small { opacity: .75; font-size: 12px; }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 44px; color: #fff; width: 48px; height: 80px; opacity: .6; z-index: 2; text-align: center; }
.viewer-nav:hover { opacity: 1; }
.viewer-nav.prev { inset-inline-start: 4px; }
.viewer-nav.next { inset-inline-end: 4px; }
[dir="rtl"] .viewer-nav.prev { left: auto; }
.viewer-cap { text-align: center; padding: 12px 16px calc(16px + var(--safe-b)); max-height: 30vh; overflow-y: auto; }
.viewer-cap:empty { display: none; }
.viewer-cap a { color: #8fd3ff; }
@media (pointer: coarse) { .viewer-nav { display: none; } }

/* ---------- paneles de info */
.info-top { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 16px 18px; background: var(--panel); }
.info-top h2 { margin: 12px 0 2px; font-size: 22px; font-weight: 500; }
.info-top p { margin: 2px 0; }
.info-top .btn { margin-top: 12px; }
.info-sec { border-top: 8px solid var(--bg); padding: 6px 0; }
.sec-title { padding: 8px 16px 4px; color: var(--muted); font-size: 14px; }
.info-sec > .input { margin: 4px 12px; width: calc(100% - 24px); }
.desc { padding: 8px 16px; white-space: pre-wrap; }
.info-actions { display: flex; gap: 12px; margin-top: 14px; }
.round-act { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--accent-2); min-width: 86px; }
.round-act small { color: var(--text); font-size: 13px; }
.avatar-edit { position: relative; }
.avatar-edit .cam { position: absolute; bottom: 4px; inset-inline-end: 4px; background: var(--accent); color: #fff; border-radius: 50%; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.more-btn { margin: 6px auto; display: block; }
.report-card { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.report-card .row-sub { white-space: normal; }
.report-msg { background: var(--quote); border-radius: 6px; padding: 6px 10px; margin: 6px 0; font-size: 14px; word-break: break-word; }
.gallery { padding: 4px; }
.gallery .file-card, .gallery .voice, .gallery .link-card { margin: 6px 8px; max-width: none; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.media-cell { position: relative; aspect-ratio: 1; background: var(--quote); overflow: hidden; }
.media-cell img { width: 100%; height: 100%; object-fit: cover; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lang-btn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.lang-btn.on { border-color: var(--accent); background: var(--chip-on); }
.lang-btn .big { font-size: 22px; }
.onb .panel-body { padding: 8px 16px; }
.onb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.onb-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border: 2px solid var(--line); border-radius: 14px; text-align: center; font-size: 14px; font-weight: 500; }
.onb-card.on { border-color: var(--accent); background: var(--chip-on); }
.onb-check { position: absolute; top: 6px; inset-inline-end: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: none; align-items: center; justify-content: center; }
.onb-card.on .onb-check { display: flex; }

/* ---------- estados */
.st-ring { padding: 2px; border-radius: 50%; border: 2.5px solid var(--accent); display: flex; }
.st-ring.seen { border-color: var(--muted); opacity: .9; }
.my-status .row-main { cursor: pointer; }
.st-me { display: flex; }
.st-plus { position: absolute; bottom: -2px; inset-inline-end: -2px; background: var(--accent); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--panel); }
.st-compose { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; transition: background .2s; }
.st-text-in { width: 100%; max-width: 600px; background: transparent; border: 0; outline: none; color: #fff; font-size: 30px; text-align: center; resize: none; min-height: 40vh; }
.st-text-in::placeholder { color: rgba(255,255,255,.7); }
.st-send { position: absolute; bottom: calc(24px + var(--safe-b)); inset-inline-end: 24px; }
.st-bars { position: absolute; top: calc(6px + var(--safe-t)); left: 8px; right: 8px; display: flex; gap: 3px; z-index: 4; }
.st-bars i { flex: 1; height: 3px; background: rgba(255,255,255,.35); border-radius: 2px; overflow: hidden; }
.st-bars b { display: block; height: 100%; width: 0; background: #fff; }
.st-viewer .viewer-head { padding-top: calc(16px + var(--safe-t)); }
.st-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.st-stage img, .st-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.st-textview { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px; font-size: 28px; text-align: center; white-space: pre-wrap; }
.st-foot { position: absolute; bottom: 0; left: 0; right: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.st-views { color: #fff; display: flex; align-items: center; gap: 4px; padding: 12px 16px calc(14px + var(--safe-b)); }
.st-tap { position: absolute; top: 80px; bottom: 80px; width: 35%; z-index: 3; }
.st-tap.left { left: 0; } .st-tap.right { right: 0; }
.st-viewer:has(.st-reply) .st-foot { padding-bottom: 52px; } /* el boton Responder tapaba el comentario */
.st-reply { position: absolute; bottom: calc(16px + var(--safe-b)); left: 50%; transform: translateX(-50%); color: #fff; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 20px; background: rgba(255,255,255,.15); }
.st-time { opacity: .75; }

/* ---------- llamadas */
.call-screen { background: radial-gradient(circle at 50% 30%, #1f3b36, #0b141a 70%); align-items: center; justify-content: space-between; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.call-screen.live .call-remote { display: block; }
.call-screen.live .call-info { background: linear-gradient(rgba(0,0,0,.55), transparent); padding-bottom: 30px; }
.call-screen.live .call-info .avatar { display: none; }
.call-info { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; padding: calc(56px + var(--safe-t)) 16px 0; width: 100%; text-align: center; }
.call-info h2 { margin: 16px 0 4px; font-weight: 500; font-size: 26px; }
.call-status { opacity: .8; font-variant-numeric: tabular-nums; }
.call-local { position: absolute; z-index: 3; width: 110px; height: 160px; object-fit: cover; border-radius: 12px; top: calc(16px + var(--safe-t)); inset-inline-end: 16px; transform: scaleX(-1); box-shadow: 0 4px 14px rgba(0,0,0,.5); background: #222; }
.call-ctrls { position: relative; z-index: 2; display: flex; gap: 22px; justify-content: center; padding: 20px 16px calc(40px + var(--safe-b)); width: 100%; background: linear-gradient(transparent, rgba(0,0,0,.5)); }
.call-btn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-btn.on { background: #fff; color: #111; }
.call-btn.end { background: #ea0038; }
.call-btn.end .ic { transform: rotate(135deg); }
.call-btn.accept { background: #00a884; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px rgba(0,168,132,.2); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(127,127,127,.35); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* llamadas de grupo (malla, max 8) */
.call-screen.gcall { justify-content: flex-start; }
.gcall-head { position: relative; z-index: 2; text-align: center; padding: calc(14px + var(--safe-t)) 16px 6px; width: 100%; }
.gcall-head h2 { margin: 0 0 2px; font-size: 18px; font-weight: 500; }
.gcall-grid { flex: 1; min-height: 0; width: 100%; display: grid; gap: 6px; padding: 6px; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
.gcall-grid:not([data-n="1"]):not([data-n="2"]) { grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) {
  .gcall-grid[data-n="2"] { grid-template-columns: 1fr 1fr; }
  .gcall-grid[data-n="5"], .gcall-grid[data-n="6"] { grid-template-columns: repeat(3, 1fr); }
  .gcall-grid[data-n="7"], .gcall-grid[data-n="8"] { grid-template-columns: repeat(4, 1fr); }
}
.gcall-tile { position: relative; min-height: 0; border-radius: 12px; overflow: hidden; background: #1f2c33; display: flex; align-items: center; justify-content: center; }
.gcall-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.gcall-tile.cam video { display: block; }
.gcall-tile.cam .avatar { display: none; }
.gcall-tile.me video { transform: scaleX(-1); }
.gcall-tile.wait { opacity: .55; }
.gcall-name { position: absolute; inset-inline-start: 8px; bottom: 8px; display: flex; align-items: center; gap: 4px; max-width: calc(100% - 16px); padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.45); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcall-name .ic { display: none; flex: none; color: #ff6b6b; }
.gcall-tile.muted .gcall-name .ic { display: block; }
.gcall-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--chip-on); color: var(--chip-on-text); border-bottom: 1px solid var(--line); z-index: 1; }
.gcall-bar-txt { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gcall-bar .btn { padding: 6px 16px; }
.gcall-faces { display: flex; }
.gcall-faces .avatar { margin-inline-start: -6px; border: 2px solid var(--panel); }
.gcall-sub { color: var(--accent); }
.gcall-join { font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---------- niveles (XP), marcos de avatar y ranking */
.lvl-chip { --lc: #8696a0; display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; margin-inline-start: 4px; padding: 0 7px 0 1px; height: 17px; border-radius: 9px; font-size: 10.5px; font-weight: 700; line-height: 1; white-space: nowrap; flex: none; max-width: 130px;
  color: var(--lc); background: color-mix(in srgb, var(--lc) 15%, transparent); }
.lvl-chip b { display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--lc); color: #fff; font-size: 9.5px; }
.sender-name .lvl-chip { margin-inline-start: 0; }
.lvl-chip.lt1 { --lc: #b06d3b; } .lvl-chip.lt2 { --lc: #7f8f9c; } .lvl-chip.lt3 { --lc: #c8920e; } .lvl-chip.lt4 { --lc: #1f9e97; }
.lvl-chip.lt5 { --lc: #3b82f6; } .lvl-chip.lt6 { --lc: #9b5de5; } .lvl-chip.lt7 { --lc: #e5484d; }
.lvl-chip.lt8 { --lc: #f97316; } .lvl-chip.lt8 b { background: linear-gradient(90deg, #ff2d00, #ffb300); }
.lvl-chip.lt9 { --lc: #e0457b; } .lvl-chip.lt9 b { background: linear-gradient(90deg, #ff4d4d, #ffb84d, #4dd96b, #4db8ff, #b44dff); }
.lvl-chip .lvl-name { overflow: hidden; text-overflow: ellipsis; }
/* marcos: anillo (mascara) encima del avatar; los altos giran y brillan. Solo transform/opacity animados (GPU) */
.avatar.framed { --fw: 3px; }
.av-frame { --fr: #8696a0; position: absolute; inset: calc(var(--fw) * -1 - 1px); border-radius: 50%; padding: var(--fw); pointer-events: none; background: var(--fr);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.av-crown { position: absolute; top: 0; left: 50%; transform: translate(-50%, -62%) rotate(-8deg); line-height: 1; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.fr-bronze { --fr: conic-gradient(#7a3f17, #e5a66b, #8c4a1f, #c98448, #7a3f17); }
.fr-silver { --fr: conic-gradient(#7d8994, #f4f7fa, #8e9aa5, #dfe5ea, #7d8994); }
.fr-gold { --fr: conic-gradient(#9c6f0c, #ffe680, #b8860b, #ffd447, #9c6f0c); }
.fr-emerald { --fr: conic-gradient(#065f46, #6ee7b7, #047857, #a7f3d0, #065f46); }
.fr-ruby { --fr: conic-gradient(#7f1d1d, #fb7185, #9f1239, #fecdd3, #7f1d1d); }
.fr-sapphire { --fr: conic-gradient(#1e3a8a, #93c5fd, #1d4ed8, #dbeafe, #1e3a8a); }
.fr-platinum { --fr: conic-gradient(#5fb8b2, #f0fffd, #4aa3b8, #e3fffb, #5fb8b2); animation: fr-spin 8s linear infinite; }
.fr-amethyst { --fr: conic-gradient(#4c1d95, #d8b4fe, #6d28d9, #f3e8ff, #4c1d95); animation: fr-spin 7s linear infinite; }
.fr-diamond { --fr: conic-gradient(#4aa8ff, #eaf7ff, #7b6cff, #c4ecff, #4aa8ff); animation: fr-spin 5s linear infinite; }
.fr-ice { --fr: conic-gradient(#e0f7ff, #67e8f9, #ffffff, #38bdf8, #e0f7ff); animation: fr-spin 5s linear infinite; }
.fr-toxic { --fr: conic-gradient(#14532d, #a3e635, #22c55e, #d9f99d, #14532d); animation: fr-spin 3s linear infinite; }
.fr-fire { --fr: conic-gradient(#ff2d00, #ffb300, #ff6d00, #ffea00, #ff2d00); animation: fr-spin 2.2s linear infinite; }
.fr-thunder { --fr: conic-gradient(#facc15, #1e1b4b, #fde047, #312e81, #facc15, #1e1b4b, #fef08a, #312e81, #facc15); animation: fr-spin 2.5s linear infinite, fr-flash 1.8s steps(1) infinite; }
.fr-neon { --fr: conic-gradient(#00f0ff, #ff00d4, #00f0ff, #7a00ff, #00f0ff); animation: fr-spin 3s linear infinite; }
.fr-galaxy { --fr: radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 2px), radial-gradient(circle at 75% 70%, #fff 0 1px, transparent 2px), conic-gradient(#1e1b4b, #7c3aed, #db2777, #1e1b4b, #2563eb, #1e1b4b); animation: fr-spin 6s linear infinite; }
.fr-aurora { --fr: conic-gradient(#22d3ee, #a78bfa, #34d399, #f472b6, #22d3ee); animation: fr-spin 4s linear infinite; }
.fr-lava { --fr: conic-gradient(#450a0a, #f97316, #7f1d1d, #fde047, #b91c1c, #450a0a); animation: fr-spin 2s linear infinite; }
.fr-rainbow { --fr: conic-gradient(#ff4d4d, #ffb84d, #fff04d, #4dd96b, #4db8ff, #7a5cff, #ff4dd2, #ff4d4d); animation: fr-spin 3s linear infinite; }
.fr-legend { --fr: conic-gradient(#ffd54a, #ff4d4d, #ffd54a, #b44dff, #ffd54a, #4db8ff, #ffd54a); animation: fr-spin 2.4s linear infinite; }
.fr-owner { --fr: conic-gradient(#8a5a00, #fff3b0, #d4a017, #fffbe6, #b8860b, #ffe680, #8a5a00); animation: fr-spin 3s linear infinite; }
.fr-admin { --fr: conic-gradient(#b91c1c, #ffd54a, #e5484d, #ffd54a, #b91c1c); animation: fr-spin 4s linear infinite; }
.fr-cadmin { --fr: conic-gradient(#1d4ed8, #5eead4, #3b82f6, #5eead4, #1d4ed8); animation: fr-spin 5s linear infinite; }
.fr-mod { --fr: conic-gradient(#047857, #a7f3d0, #00a884, #a7f3d0, #047857); animation: fr-spin 6s linear infinite; }
.fx-owner .av-frame { inset: calc(var(--fw) * -1.4 - 1px); padding: calc(var(--fw) * 1.4); } /* el del dueno, mas grueso */
/* brillo exterior (sombra del propio avatar) en los marcos altos y de staff */
.fx-fire, .fx-lava { box-shadow: 0 0 calc(var(--fw) * 3) rgba(255, 109, 0, .55); }
.fx-toxic { box-shadow: 0 0 calc(var(--fw) * 3) rgba(132, 204, 22, .5); }
.fx-thunder { box-shadow: 0 0 calc(var(--fw) * 3) rgba(250, 204, 21, .5); }
.fx-neon { box-shadow: 0 0 calc(var(--fw) * 3) rgba(255, 0, 212, .5), 0 0 calc(var(--fw) * 2) rgba(0, 240, 255, .45); }
.fx-galaxy, .fx-aurora { box-shadow: 0 0 calc(var(--fw) * 3) rgba(167, 139, 250, .55); }
.fx-rainbow { box-shadow: 0 0 calc(var(--fw) * 3) rgba(255, 77, 210, .4); }
.fx-legend, .fx-owner { box-shadow: 0 0 calc(var(--fw) * 4) rgba(255, 213, 74, .75); }
.fx-admin { box-shadow: 0 0 calc(var(--fw) * 3) rgba(229, 72, 77, .5); }
@keyframes fr-spin { to { transform: rotate(1turn); } }
@keyframes fr-flash { 0%, 86%, 92% { opacity: 1; } 89%, 95% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .av-frame { animation: none !important; } }
.xp-card { padding: 12px 16px 14px; }
.xp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.xp-pts { font-weight: 700; color: var(--accent-2); }
.xp-bar { height: 8px; border-radius: 4px; background: var(--chip); margin-top: 10px; overflow: hidden; }
.xp-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--accent), #53bdeb); transition: width .6s ease; }
.xp-sub { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.xp-streak { color: #f97316; font-weight: 600; }
.info-top + .xp-sec, .xp-sec { padding-top: 0; }
.frame-dlg { max-width: 420px; }
.frame-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.frame-cell { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 4px 10px; border-radius: 14px; font-size: 13px; text-align: center; }
.frame-cell:hover { background: var(--hover); }
.frame-cell.on { background: var(--chip-on); box-shadow: inset 0 0 0 2px var(--accent); }
.frame-cell.locked .avatar { opacity: .5; }
.frame-cell.locked span { color: var(--muted); }
.frame-cell small { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; }
.rank-av { background: linear-gradient(135deg, #ffd54a, #ff8a1a); color: #fff; }
.rank-panel .chips { margin-bottom: 4px; }
.rank-panel .hint { padding: 0 16px; }
.rank-item .rank-pos { width: 30px; flex: none; text-align: center; font-weight: 700; color: var(--muted); font-size: 15px; }
.rank-item .rank-pos.top { font-size: 22px; }
.rank-item .avatar { margin-inline-end: 2px; }
.rank-pts { font-weight: 700; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.rank-item.me { background: var(--chip-on); }
.lvlup { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; background: rgba(0,0,0,.35); animation: lvl-fade .25s ease; transition: opacity .45s; padding: 16px; }
.lvlup.out { opacity: 0; }
.lvlup-box { background: var(--panel); color: var(--text); border-radius: 22px; padding: 22px 30px 24px; text-align: center; min-width: 240px; max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.35); display: flex; flex-direction: column; align-items: center; gap: 10px; animation: lvl-pop .5s cubic-bezier(.2,1.5,.4,1); }
.lvlup-burst { font-size: 46px; line-height: 1; background: linear-gradient(135deg, #ffd54a, #ff6d00, #e0457b); -webkit-background-clip: text; background-clip: text; color: transparent; animation: fr-spin 2.5s linear infinite; }
.lvlup-title { font-size: 21px; font-weight: 800; }
.lvlup-sub { color: var(--muted); }
.lvlup-new { font-size: 13px; font-weight: 600; color: var(--accent-2); }
@keyframes lvl-pop { from { transform: scale(.6); opacity: 0; } }
@keyframes lvl-fade { from { opacity: 0; } }
