/* Mudae: respostas do bot no chat (cards de personagem, harem, casamentos e mensagens só para você). */

/* Autor "Mudae" com a etiqueta BOT, como os bots do Discord. */
.msg .avatar.mudae-avatar { display: grid; place-items: center; background: var(--brand-gradient); color: #fff; cursor: default; }
.mudae-avatar svg { fill: currentColor; }
.msg-author.bot { cursor: default; }
.msg-author.bot:hover { text-decoration: none; }
.bot-tag {
  display: inline-flex; align-items: center; height: 15px; padding: 0 4px; margin-left: 4px; border-radius: 3px;
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 600; line-height: 15px; vertical-align: 2px; letter-spacing: .02em;
}

/* "Fulano usou $w" acima da resposta. */
.mudae-invocation { cursor: default; }
.msg .mudae-invocation .avatar { width: 16px; height: 16px; font-size: 8px; margin: 0; grid-column: auto; flex-shrink: 0; }
.mudae-invocation .reply-author { cursor: pointer; }
.mudae-invocation .reply-author:hover { text-decoration: underline; }
.mudae-cmd { color: var(--link); font-weight: 500; }
.mudae-muted { color: var(--text-muted); }

/* Card (como um embed do Discord): borda colorida à esquerda, amarela livre, vermelha com dono. */
.mudae-card {
  position: relative; display: flex; flex-direction: column; gap: 4px;
  width: fit-content; min-width: min(220px, 100%); max-width: min(100%, 320px); margin-top: 6px; padding: 14px 16px;
  background: var(--bg-panel); border: 1px solid var(--divider); border-left: 3px solid var(--yellow); border-radius: 12px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .12);
}
.mudae-card.owned { border-left-color: var(--red); }
.mudae-card.harem { border-left-color: var(--brand); min-width: min(100%, 320px); max-width: min(100%, 540px); }
.mudae-name { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--text-strong); overflow-wrap: anywhere; }
.mudae-series { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.mudae-value { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 14px; color: var(--text); }
.mudae-value strong { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.mudae-kakera { display: inline-flex; color: var(--brand); }
/* O kakera no começo de uma linha do bot (ou no saldo) é um símbolo no meio do texto. */
:is(.mudae-line, .msg-text, .salon-status-pill > span) > .mudae-kakera { margin-right: .3em; vertical-align: -.2em; }
.mudae-li-rank.medal { display: inline-flex; align-items: center; justify-content: center; }
.mudae-hint { margin-top: 4px; font-size: 13px; color: var(--text-muted); }
.mudae-img {
  display: block; width: 225px; max-width: 100%; aspect-ratio: 225 / 350; margin-top: 10px; object-fit: cover;
  border-radius: 8px; background: var(--bg-input); cursor: zoom-in;
}
.mudae-img.missing { display: grid; place-items: center; font-size: 64px; font-weight: 700; color: var(--text-muted); cursor: default; }
.mudae-footer { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.mudae-footer strong { font-weight: 600; }
.mudae-footer.warn { color: var(--yellow); }
.msg .mudae-card .avatar { width: 20px; height: 20px; font-size: 9px; margin: 0; grid-column: auto; flex-shrink: 0; cursor: default; }

/* Botão de casar: a barra embaixo esvazia nos 45 segundos. */
.mudae-actions { display: flex; gap: 8px; margin-top: 8px; }
.mudae-claim {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 10px;
  border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: color-mix(in srgb, var(--red) 16%, var(--bg-input)); color: var(--text-strong);
  transition: transform .1s ease, opacity .15s ease;
}
.mudae-claim:hover:not(:disabled) { background: var(--red); color: #fff; }
.mudae-claim:active:not(:disabled) { transform: translateY(1px); }
.mudae-claim:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.mudae-heart { display: inline-flex; color: var(--red); transition: none; }
.mudae-heart svg { fill: currentColor; }
.mudae-claim:hover:not(:disabled) .mudae-heart { color: #fff; }
.mudae-claim:hover:not(:disabled) .mudae-heart svg { animation: mudae-beat .9s ease-in-out 2; }
.mudae-timer { min-width: 26px; font-size: 12px; font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mudae-claim:hover:not(:disabled) .mudae-timer { color: rgba(255, 255, 255, .8); }
.mudae-drain {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; background: var(--red);
  transform-origin: left; animation-name: mudae-drain; animation-timing-function: linear; animation-fill-mode: forwards;
}
.mudae-claim:hover:not(:disabled) .mudae-drain { background: rgba(255, 255, 255, .7); }
.mudae-claim.pending { opacity: .7; cursor: progress; }
.mudae-claim.expired { background: var(--bg-input); color: var(--text-muted); cursor: not-allowed; opacity: .7; }
.mudae-claim.expired .mudae-heart { color: var(--text-muted); }
@keyframes mudae-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes mudae-beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }

/* Casamentos e divórcios. */
.mudae-line { color: var(--text); }
.mudae-line strong { color: var(--text-strong); }
.msg-new .mudae-line.married { animation: mudae-pop .5s cubic-bezier(.2, 1.4, .4, 1); transform-origin: left center; }
@keyframes mudae-pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Harem: lista paginada com a foto do personagem em destaque ao lado. */
.mudae-harem-head { display: flex; align-items: center; gap: 8px; }
.msg .mudae-card .avatar.mudae-head-avatar { width: 24px; height: 24px; font-size: 10px; }
.mudae-harem-body { display: flex; align-items: flex-start; gap: 16px; margin-top: 8px; }
.mudae-harem-list { flex: 1; min-width: 0; margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 1.6; color: var(--text); }
.mudae-harem-list li { padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 6px; outline: none; }
.mudae-li-rank { display: inline-block; min-width: 24px; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.mudae-harem-list li:hover, .mudae-harem-list li:focus-visible { background: var(--hover); }
.mudae-harem-list strong { color: var(--text-strong); font-weight: 600; }
.mudae-li-value { margin-left: 6px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mudae-img.mudae-thumb { width: 110px; margin-top: 2px; flex-shrink: 0; }
.mudae-pager { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.mudae-pager button {
  display: grid; place-items: center; width: 32px; height: 30px; border: 1px solid var(--divider); border-radius: 8px;
  background: var(--bg-input); color: var(--interactive); cursor: pointer; transition: none;
}
.mudae-pager button:hover { background: var(--hover-strong); color: var(--text-strong); }

/* $tu e mensagens "só você pode ver". */
.mudae-status { display: grid; gap: 2px; color: var(--text); }
.mudae-status strong { color: var(--text-strong); }
.mudae-status .mudae-ok { color: var(--green); }
.msg.ephemeral, .msg.ephemeral:hover { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.mudae-ephemeral { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.mudae-ephemeral .link-button { padding: 0; border: 0; background: none; font: inherit; color: var(--link); cursor: pointer; }
.mudae-ephemeral .link-button:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .mudae-img.mudae-thumb { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mudae-claim:hover:not(:disabled) .mudae-heart svg, .msg-new .mudae-line.married { animation: none; }
}

/* ---------- comandos novos: listas com dono, cristal, desejos, troca e avisos ---------- */
/* Linha de uma lista ($top, $obra, $wl, $topserv): posição, nome · obra, valor e o dono à direita. */
.mudae-card.list { max-width: min(100%, 600px); }
.mudae-char-list li, .mudae-serv-list li { display: flex; align-items: center; gap: 6px; }
.mudae-li-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mudae-char-list .mudae-li-value, .mudae-serv-list .mudae-li-value { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: 0; }
.mudae-li-value .mudae-kakera svg { width: 12px; height: 12px; }
.mudae-owner { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; max-width: 120px; font-size: 12px; font-weight: 600; }
.mudae-owner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mudae-owner.free { color: var(--green); font-weight: 500; }
.msg .mudae-card .avatar.mudae-owner-avatar { width: 16px; height: 16px; font-size: 8px; }
.mudae-progress { height: 6px; margin-top: 6px; border-radius: 999px; background: var(--bg-input); overflow: hidden; }
.mudae-progress span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.mudae-footer.wish { color: var(--yellow); }
.mudae-footer.wish svg { fill: currentColor; }

/* Troca no chat: aberta com o botão, ou o que cada um deu. */
.mudae-card.trade { border-left-color: var(--brand); }
.mudae-card.trade.done { border-left-color: var(--green); }
.mudae-trade-side { color: var(--text); font-size: 14px; }
.mudae-line.trade.canceled { color: var(--text-muted); }

/* Painel da troca: as duas ofertas lado a lado, o harem para escolher embaixo. */
.mudae-trade-overlay { position: fixed; inset: 0; z-index: 46; display: grid; place-items: center; padding: 16px; background: #000a; }
.mudae-trade {
  display: flex; flex-direction: column; gap: 14px; width: min(860px, 100%); max-height: calc(100dvh - 32px); padding: 18px 20px;
  overflow-y: auto; background: var(--bg-main); border-radius: 14px; box-shadow: var(--elev-3), var(--edge-light);
}
.mudae-trade-head { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.mudae-trade-head h2 { flex: 1; min-width: 0; margin: 0; overflow: hidden; color: var(--text-strong); font-size: 20px; text-overflow: ellipsis; white-space: nowrap; }
.mudae-trade-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); flex-shrink: 0; }
.mudae-trade-timer { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mudae-notice-close {
  display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border: 0; border-radius: 8px; background: transparent;
  color: var(--text-muted); cursor: pointer; transition: none;
}
.mudae-notice-close:hover { background: var(--hover); color: var(--text-strong); }
.mudae-trade-sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: stretch; }
.mudae-trade-arrow { display: grid; place-items: center; color: var(--text-muted); font-size: 22px; }
.mudae-trade .mudae-trade-side {
  display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 12px; border-radius: 12px; background: var(--bg-panel);
  box-shadow: inset 0 0 0 1px var(--divider);
}
.mudae-trade .mudae-trade-side.ok { box-shadow: inset 0 0 0 2px var(--green); }
.mudae-trade-side-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mudae-trade-side-head h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; color: var(--text-strong); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.avatar.mudae-trade-avatar { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
.mudae-trade-ok { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--green); font-size: 12px; font-weight: 700; }
.mudae-trade-wait { flex-shrink: 0; color: var(--text-muted); font-size: 12px; }
.mudae-trade-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.mudae-trade-empty { padding: 14px 4px; color: var(--text-muted); font-size: 13px; text-align: center; }
.mudae-trade-card {
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 4px 4px 6px; border: 0; border-radius: 10px;
  background: var(--bg-floating); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--frame, var(--divider)) 60%, transparent);
  color: var(--text); font: inherit; text-align: left;
}
button.mudae-trade-card { cursor: pointer; transition: none; }
button.mudae-trade-card:hover { background: var(--bg-input); }
button.mudae-trade-card:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.mudae-trade-card.selected { box-shadow: inset 0 0 0 2px var(--brand); }
.mudae-trade-card img, .mudae-trade-img-missing { display: grid; place-items: center; width: 100%; aspect-ratio: 3 / 4; border-radius: 7px; object-fit: cover; background: var(--bg-input); color: var(--text-muted); font-size: 24px; font-weight: 700; }
.mudae-trade-card-name { overflow: hidden; color: var(--text-strong); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mudae-trade-card-value { display: inline-flex; align-items: center; gap: 2px; color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mudae-trade-card-value svg { width: 11px; height: 11px; }
.mudae-trade-remove, .mudae-trade-check {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .72); color: #fff; cursor: pointer;
}
.mudae-trade-check { background: var(--brand); cursor: inherit; }
.mudae-trade-remove:hover { background: var(--red); }
.mudae-trade-kakera { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.mudae-trade-kakera-input { width: 96px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: var(--bg-input); color: var(--text-strong); font: inherit; font-variant-numeric: tabular-nums; }
.mudae-trade-kakera-input:focus { outline: none; box-shadow: 0 0 0 2px var(--brand); }
.mudae-trade-pick-bar { display: flex; justify-content: center; }
.mudae-trade-picker { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--bg-panel); }
.mudae-trade-picker .salon-search { flex: none; }
.mudae-trade-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.mudae-trade-note { margin: 0; color: var(--text-muted); font-size: 13px; text-align: center; }
.mudae-trade-actions { display: flex; justify-content: flex-end; gap: 8px; }
.mudae-trade-actions button { border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.mudae-trade-actions .btn-ghost { background: none; color: var(--text); }
.mudae-trade-actions .btn-ghost:hover { text-decoration: underline; }
.mudae-trade-actions .btn-primary { background: var(--green); color: #fff; }
.mudae-trade-actions .btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.mudae-trade-actions .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.mudae-trade-actions .mudae-trade-undo { box-shadow: inset 0 0 0 1px var(--divider); }
.mudae-trade-actions .mudae-trade-undo:hover { text-decoration: none; background: var(--hover); }

/* Avisos com botão (convite de troca, desejado que saiu): no canto, acima do campo de mensagem. */
#mudae-notices { position: fixed; right: 16px; bottom: 88px; z-index: 47; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.mudae-notice {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 12px; background: var(--bg-floating);
  box-shadow: var(--shadow-float), inset 0 0 0 1px var(--divider); color: var(--text); font-size: 14px; pointer-events: auto;
  animation: mudae-pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.mudae-notice-icon { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); }
.mudae-notice-img { width: 40px; height: 56px; flex-shrink: 0; border-radius: 6px; object-fit: cover; background: var(--bg-input); }
.mudae-notice-text { flex: 1; min-width: 0; line-height: 1.35; }
.mudae-notice .mudae-go { flex-shrink: 0; white-space: nowrap; }

@media (max-width: 640px) {
  .mudae-trade { padding: 14px; }
  .mudae-trade-sides { grid-template-columns: minmax(0, 1fr); }
  .mudae-trade-arrow { transform: rotate(90deg); }
  .mudae-trade-cards, .mudae-trade-pick-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .mudae-trade-actions { flex-direction: column-reverse; }
  .mudae-trade-actions button { width: 100%; }
  #mudae-notices { top: 12px; right: 12px; bottom: auto; }
  .mudae-owner { max-width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .mudae-notice { animation: none; }
}

/* Aviso "Seus rolls voltaram!" (fica na pilha de avisos do canto, com o visual do aviso do Clipar). */
.mudae-rolls-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 16%, var(--bg-panel)); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  animation: mudae-rolls-shake .6s var(--ease-enter) .15s;
}
@keyframes mudae-rolls-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg) scale(1.06); } 60% { transform: rotate(10deg); } }
:root[data-reduce-motion=true] .mudae-rolls-icon { animation: none; }
/* Chaves: o selo no nome do personagem (bronze, prata, ouro e caos) */
.mudae-key { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.4; vertical-align: middle; font-variant-numeric: tabular-nums; }
.mudae-key svg { flex: none; }
/* Bronze, prata e ouro são os metais da Forja (tokens em mudae-salao.css); a de caos usa o roxo da marca e o rosa do Desejo. */
.mudae-key.key-bronze { background: var(--metal-bronze); color: var(--metal-bronze-ink); }
.mudae-key.key-prata { background: var(--metal-prata); color: var(--metal-prata-ink); }
.mudae-key.key-ouro { background: var(--metal-ouro); color: var(--metal-ouro-ink); box-shadow: 0 0 6px color-mix(in srgb, var(--metal-ouro) 55%, transparent); }
.mudae-key.key-caos { background: linear-gradient(135deg, var(--brand), var(--poder-desejo)); color: #fff; box-shadow: 0 0 8px color-mix(in srgb, var(--brand) 60%, transparent); }
.mudae-footer.key { display: flex; align-items: center; gap: 4px; }
