:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel2: #f3f2ee;
  --line: #e4e1d9;
  --text: #24263a;
  --muted: #73778c;
  --accent: #5b5fc7;
  --accent-soft: #ecedfb;
  --ok: #2fb46a;
  --warn: #e9a23b;
  --bad: #e0524f;
  --ink: #1f2133;
  --r: 6px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled) { border-color: #c9c5bb; background: #fbfaf7; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #4c50b8; border-color: #4c50b8; }
button.big { width: 100%; padding: 12px; font-size: 15px; }
button.link { background: none; border: 0; color: var(--bad); padding: 4px 6px; }
button.icon { background: none; border: 0; padding: 6px; color: var(--muted); }
button.icon:hover { color: var(--text); background: var(--panel2); }
input, select, textarea {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
canvas#world:focus { outline: none; }
label, .label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 14px; }
label.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.01em; }
h2 { margin: 0 0 14px; font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; line-height: 1.45; }
.hint.small { font-size: 12px; margin: 6px 2px 0; }
.center-text { text-align: center; }
.err { color: var(--bad); min-height: 1em; margin: 2px 0 10px; font-size: 13px; }
.sub { color: var(--muted); margin: 0 0 20px; line-height: 1.45; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.center-row { justify-content: center; }
a { color: var(--accent); }

/* marca */
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; margin-bottom: 8px; }
.logo.small { font-size: 16px; margin: 0; }
.logo-mark { width: 22px; height: 22px; display: inline-block; background:
  linear-gradient(var(--accent) 0 0) 0 0 / 10px 10px no-repeat,
  linear-gradient(#f2b45c 0 0) 12px 0 / 10px 10px no-repeat,
  linear-gradient(#2fb46a 0 0) 0 12px / 22px 10px no-repeat; }
.logo.small .logo-mark { width: 16px; height: 16px; background-size: 7px 7px, 7px 7px, 16px 7px; background-position: 0 0, 9px 0, 0 9px; }

/* telas de entrada */
.auth-wrap { position: relative; min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background: repeating-linear-gradient(0deg, #f6e6cf 0 15px, #efdcc1 15px 16px); }
.auth-bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0.9; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: min(460px, 100%); box-shadow: 0 12px 40px rgba(60,50,30,0.12); }
.prejoin { width: min(560px, 100%); display: grid; gap: 14px; }
.prejoin .sub { margin-bottom: 0; }
.prejoin-strip#av-strip { position: static; transform: none; max-width: none; display: block; }
.prejoin-strip .tile { width: 100%; height: 290px; }

.look { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.look-preview { background: repeating-linear-gradient(0deg, #f6e6cf 0 15px, #efdcc1 15px 16px); border-radius: var(--r); border: 1px solid var(--line); image-rendering: pixelated; }
.look-row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 12px; color: var(--muted); }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.sw { width: 24px; height: 24px; padding: 0; border-radius: 4px; border: 1px solid rgba(0,0,0,0.12); }
.sw.txt { width: auto; padding: 0 8px; font-size: 12px; background: var(--panel2); }
.sw.on { outline: 2px solid var(--accent); outline-offset: 1px; }

/* escritório */
.office { position: relative; height: 100%; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.topleft { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; align-items: center; z-index: 4; flex-wrap: wrap; max-width: calc(100% - 28px); }
.topleft .logo { background: var(--panel); padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(40,30,20,0.08); }
.area-pill { display: flex; align-items: center; gap: 8px; background: rgba(31,33,51,0.88); color: #fff; padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.area-pill em { font-style: normal; font-weight: 400; color: #c7c9dc; }
.net { background: var(--warn); color: #221a08; padding: 7px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.net[hidden] { display: none; }

#av-strip { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; max-width: calc(100% - 28px); overflow-x: auto; z-index: 3; padding: 2px; }
.office.with-panel #av-strip { left: calc(50% - 180px); max-width: calc(100% - 400px); }
.tile { position: relative; width: 180px; height: 120px; background: #2a2c3d; border-radius: 10px; overflow: hidden; flex: none; cursor: pointer; box-shadow: 0 6px 18px rgba(30,20,10,0.18); border: 2px solid transparent; }
.tile[hidden] { display: none; }
.tile.falando { border-color: var(--ok); }
.tile-media, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.tela video { object-fit: contain; background: #000; }
.tile video.espelho { transform: scaleX(-1); }
.tile-off { height: 100%; display: grid; place-items: center; color: #b6b8c9; font-size: 12px; }
.tile-name { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; background: rgba(20,22,34,0.75); color: #fff; font-size: 12px; font-weight: 600; border-radius: 999px; }
.tile.mudo .tile-name::after { content: " · mudo"; color: #ff9b97; font-weight: 500; }
/* vídeo ampliado: janela centralizada no formato do vídeo, imagem inteira (sem corte) */
#av-stage { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%);
  width: min(960px, calc(100vw - 48px), calc((100vh - 260px) * 16 / 9)); aspect-ratio: 16 / 9;
  background: #111; border-radius: 12px; z-index: 5; overflow: hidden; box-shadow: 0 16px 50px rgba(0,0,0,0.35); }
.office.with-panel #av-stage { left: calc(50% - 180px); width: min(960px, calc(100vw - 440px), calc((100vh - 260px) * 16 / 9)); }
#av-stage[hidden] { display: none; }
#av-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#av-stage video.espelho { transform: scaleX(-1); }
.stage-close { position: absolute; top: 10px; right: 10px; z-index: 1; }

/* barra inferior */
.dock { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); padding: 8px; border-radius: 14px; z-index: 6;
  box-shadow: 0 10px 30px rgba(40,30,20,0.16); max-width: calc(100% - 24px); }
.office.with-panel .dock { left: calc(50% - 180px); }
.dock .sep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.round { width: 42px; height: 42px; padding: 0; border-radius: 10px; background: var(--panel2); border-color: transparent; }
.round:hover:not(:disabled) { background: #e9e7e1; border-color: transparent; }
.round.off { background: #fdecea; color: var(--bad); }
.round.off:hover:not(:disabled) { background: #fbdcd9; }
.round.active { background: var(--accent); color: #fff; }
.tabbtn { height: 42px; border-radius: 10px; background: var(--panel2); border-color: transparent; position: relative; font-weight: 600; }
.tabbtn:hover:not(:disabled) { background: #e9e7e1; border-color: transparent; }
.tabbtn.active { background: var(--accent-soft); color: var(--accent); }
.badge { position: absolute; top: -5px; right: -5px; background: var(--bad); color: #fff; font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; }
.badge[hidden] { display: none; }
.me-box { display: flex; align-items: center; gap: 8px; padding-right: 4px; }
.me-mini { width: 36px; height: 36px; background: var(--panel2); border-radius: 8px; image-rendering: pixelated; }
.me-txt { display: grid; line-height: 1.15; }
.me-txt strong { font-size: 13px; }
.status-sel { border: 0; padding: 0; background: none; font-size: 12px; color: var(--muted); cursor: pointer; width: auto; }
.status-sel:focus { outline: none; text-decoration: underline; }

/* painel lateral */
.panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; z-index: 7;
  display: grid; grid-template-rows: auto 1fr; box-shadow: 0 12px 40px rgba(40,30,20,0.16); min-height: 0; }
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 8px 16px; font-size: 15px; }
.panel-body { overflow-y: auto; padding: 0 10px 12px; min-height: 0; }
.group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 6px 6px; }
.member { width: 100%; justify-content: flex-start; gap: 10px; text-align: left; background: transparent; border-color: transparent; padding: 7px 6px; }
.member:hover:not(:disabled) { background: var(--panel2); border-color: transparent; }
.member.off { opacity: 0.55; }
.face-wrap { position: relative; flex: none; }
.face { width: 34px; height: 34px; background: var(--panel2); border-radius: 8px; image-rendering: pixelated; display: block; }
.face-wrap .dot { position: absolute; right: -2px; bottom: -2px; border: 2px solid #fff; }
.m-txt { display: grid; min-width: 0; }
.m-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.m-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.disponivel { background: var(--ok); }
.dot.ocupado { background: var(--bad); }
.dot.ausente { background: var(--warn); }
.dot.off { background: #d9d6ce; }
.invite-cta { width: 100%; margin-top: 14px; border-style: dashed; color: var(--accent); }

/* chat */
.panel-body.chat { display: grid; grid-template-rows: auto 1fr auto; padding: 0; }
.tabs { display: flex; gap: 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: transparent; border-color: transparent; padding: 6px 10px; border-radius: 999px; font-weight: 500; color: var(--muted); }
.tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tab b { background: var(--bad); color: #fff; font-size: 11px; padding: 0 6px; border-radius: 9px; }
.msgs { overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.msg { padding: 2px 0; }
.msg:not(.cont) { margin-top: 10px; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .meta strong { color: var(--text); font-size: 13px; }
.msg.mine .meta strong { color: var(--accent); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }
.send { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.send-row { display: flex; gap: 6px; align-items: flex-end; }
.send textarea { resize: none; max-height: 120px; }
.send-btn { color: var(--accent); }

/* menus, avisos, diálogos */
.pop { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 2px; min-width: 210px; box-shadow: 0 12px 32px rgba(40,30,20,0.18); }
.pop button { justify-content: flex-start; background: transparent; border-color: transparent; padding: 8px 10px; }
.pop button:hover { background: var(--panel2); }
.pop-head { display: grid; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
#toasts { position: fixed; right: 16px; bottom: 90px; display: grid; gap: 8px; z-index: 30; }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,0.25); font-weight: 500; }
.toast button { background: var(--accent); border-color: var(--accent); color: #fff; padding: 6px 12px; }
.tips { position: absolute; left: 14px; bottom: 16px; width: 320px; z-index: 5; padding: 18px; }
.tips ul { margin: 10px 0 14px; padding-left: 18px; color: var(--muted); line-height: 1.55; font-size: 13px; }
dialog.dlg { color: var(--text); width: min(540px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(30,25,15,0.35); }
.invites { display: grid; gap: 12px; margin-top: 16px; }
.inv { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.inv .m-sub { grid-column: 1; }

@media (max-width: 900px) {
  .panel { left: 8px; right: 8px; width: auto; top: auto; height: 60vh; bottom: 84px; }
  .office.with-panel .dock, .office.with-panel #av-strip { left: 50%; max-width: calc(100% - 24px); }
  .area-pill em, .me-txt, .tips { display: none; }
  .tile { width: 120px; height: 84px; }
  .dock { gap: 4px; padding: 6px; }
  .round, .tabbtn { width: 38px; height: 38px; }
  .tabbtn span:not(.count) { display: none; }
}

/* cargos e aprovação */
.role-tag { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.role-tag.gestao { background: #e6f5ec; color: #1f7a48; }
.role-tag.admin { background: var(--accent-soft); color: var(--accent); }
.pop-roles { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 6px 4px; display: grid; gap: 6px; }
.seg { display: flex; gap: 4px; }
.pop .seg button { flex: 1; justify-content: center; padding: 6px 6px; font-size: 12px; border: 1px solid var(--line); }
.pop .seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.toast { max-width: 420px; flex-wrap: wrap; }
.toast-actions { display: flex; gap: 6px; }
.toast-actions button:not(.primary) { background: transparent; border-color: #4a4d66; color: #fff; }

body.with-panel #toasts { right: 388px; }
@media (max-width: 900px) { body.with-panel #toasts { right: 16px; bottom: calc(60vh + 96px); } }

/* senha */
.pw { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.pw summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.pw .row { margin-top: 10px; flex-wrap: nowrap; }
.pw input { min-width: 0; }
.auth .hint.center-text p { margin: 8px 0 0; }

/* microfone: nível captado */
.meter { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 8px 0 12px; }
.meter i { display: block; height: 100%; width: calc(var(--mic, 0) * 100%); background: var(--ok); transition: width .08s linear; }
.round.mic-btn:not(.off) { box-shadow: inset 0 calc(-42px * var(--mic, 0)) 0 rgba(47, 180, 106, 0.35); }
.devs label { margin-bottom: 10px; }

/* mapa */
.minimap { width: 100%; display: block; border-radius: 8px; border: 1px solid var(--line); cursor: crosshair; margin: 8px 0 4px; background: #9bd383; }
.place { width: 100%; justify-content: flex-start; gap: 10px; background: transparent; border-color: transparent; padding: 8px 8px; text-align: left; }
.place:hover:not(:disabled) { background: var(--panel2); border-color: transparent; }
.place .m-sub { margin-left: auto; }
.place svg { color: var(--muted); flex: none; }

/* chat em canais */
.panel.wide { width: 620px; }
.office.with-panel:has(.panel.wide) .dock, .office.with-panel:has(.panel.wide) #av-strip { left: calc(50% - 310px); }
.ch-wrap { display: grid; grid-template-columns: 190px 1fr; height: 100%; min-height: 0; }
.ch-side { border-right: 1px solid var(--line); overflow-y: auto; padding: 0 8px 12px; }
.ch-item { width: 100%; justify-content: flex-start; gap: 8px; background: transparent; border-color: transparent; padding: 6px 8px; color: var(--muted); font-weight: 500; }
.ch-item:hover:not(:disabled) { background: var(--panel2); border-color: transparent; color: var(--text); }
.ch-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ch-item.unread { color: var(--text); font-weight: 700; }
.ch-item .ch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; text-align: left; }
.ch-item b { background: var(--bad); color: #fff; font-size: 11px; padding: 0 6px; border-radius: 9px; }
.ch-item b.at { background: var(--accent); }
.ch-add { width: 100%; margin-top: 4px; border-style: dashed; color: var(--accent); font-size: 13px; padding: 6px; }
.ch-main { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.ch-head { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 10px 14px; border-bottom: 1px solid var(--line); }
.ch-title { display: grid; gap: 2px; min-width: 0; }
.ch-title strong { font-size: 15px; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); background: var(--panel2); padding: 1px 6px; border-radius: 4px; width: fit-content; }
.mention { background: var(--accent-soft); color: var(--accent); font-weight: 600; padding: 0 3px; border-radius: 3px; }
.mention.me { background: #fff1c2; color: #8a5a00; }
.msg.pinged { background: #fff9e6; border-left: 3px solid #e9a23b; padding-left: 8px; margin-left: -11px; }
.send { position: relative; }
.suggest { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(40,30,20,0.16); padding: 4px; display: grid; gap: 2px; max-height: 280px; overflow-y: auto; z-index: 3; }
.suggest[hidden] { display: none; }
.sg { justify-content: flex-start; gap: 10px; background: transparent; border-color: transparent; padding: 7px 10px; }
.sg.on, .sg:hover { background: var(--accent-soft); }
.badge.at { background: var(--accent); }
.members-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 10px; }
.members-pick[hidden] { display: none; }
.members-pick label { font-size: 13px; color: var(--text); }
.members-pick input, label.inline input[type=checkbox] { width: auto; }
/* relatório */
dialog.dlg.wide { width: min(860px, calc(100% - 32px)); }
.chip { padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.report { margin-top: 14px; overflow-x: auto; }
.report table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.report td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.report .num { text-align: right; font-variant-numeric: tabular-nums; }
.report tr.zero td { color: var(--muted); }
@media (max-width: 900px) { .panel.wide { width: auto; } .ch-wrap { grid-template-columns: 120px 1fr; } }

/* editor de personagem */
dialog.dlg:has(.look) { width: min(720px, calc(100% - 32px)); }
.look { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.look-left { display: grid; gap: 8px; }
.look-preview { width: 200px; height: 220px; }
.look-tools { justify-content: space-between; gap: 6px; }
.look-tools button { flex: 1; padding: 6px 0; }
.look-right { min-width: 0; }
.look-tabs { padding: 0 0 8px; margin-bottom: 10px; }
.look-row { grid-template-columns: 92px 1fr; }
.sw.excl { background: linear-gradient(135deg, #1a1f2e, #2a4a8a); color: #dff3ff; border-color: #3d8bff; }
.sw.excl.on { box-shadow: 0 0 10px rgba(80,180,255,0.7); }
.look-note:empty { display: none; }
@media (max-width: 560px) { .look { grid-template-columns: 1fr; } .look-left { justify-items: center; } }
.card:has(.look) { width: min(720px, 100%); }
