/* Só o cliente do navegador usa a área visível e as bordas do aparelho. */
html.web-shell, body.web-viewer { overflow: hidden; overscroll-behavior: none; }
body.web-viewer {
  --edge-top: env(safe-area-inset-top, 0px);
  --edge-bottom: env(safe-area-inset-bottom, 0px);
  --edge-left: env(safe-area-inset-left, 0px);
  --edge-right: env(safe-area-inset-right, 0px);
  --nav-h: 62px;
  position: absolute; inset: var(--web-top, 0px) 0 auto; width: 100%;
  height: 100svh; height: var(--web-height, 100dvh);
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
.web-viewer [hidden] { display: none !important; }
.web-viewer :is(button, [role=button], [role=menuitem], summary, label:has(input[type=checkbox])) {
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.web-viewer :is(button, summary, [role=button][tabindex], [role=menuitem], [role=menu] > a,
  input:not([type=file]), select, textarea) { min-inline-size: 44px; min-block-size: 44px; }
.web-viewer :is(button, summary, [role=button]):not(:disabled):active { filter: brightness(.86); }
.web-viewer :is(#home, #modal-root, #chat, #call, #ctx-menu) :is(input:not([type=file]), select, textarea) {
  min-width: 44px; min-height: 44px; max-inline-size: 100%; font-size: max(16px, 1em);
}
.web-viewer #titlebar, .web-viewer #home .home-tip { display: none; }
.web-viewer .screen { inset: 0; }
.web-viewer :is(#home, #call-stage, #messages, #channels, .modal .body, .right-dm, .nmenu, #ctx-menu, .focus-strip) {
  overscroll-behavior: contain; scrollbar-width: thin;
}
.web-viewer #home .home-wrap {
  width: min(100%, 35rem); padding: calc(var(--edge-top) + 24px) max(20px, var(--edge-right))
  calc(var(--edge-bottom) + 24px) max(20px, var(--edge-left));
}
.web-viewer #home .home-brand { margin-bottom: 8px; }
.web-viewer #home .home-brand p { font-size: 15px; }
.web-viewer #home .home-logo img { width: 52px; height: 52px; }
.web-viewer #home .home-join { gap: 10px; }
.web-viewer #home .home-row .field { flex: 1 1 100%; min-width: 0; }
.web-viewer #home .home-row #btn-join { width: 100%; }
.web-viewer #home .home-more summary { padding-block: 12px; }
.web-viewer #home #join-addr { font-size: 20px; }
.web-viewer #home .field input:not([type=color]):not([type=checkbox]):not(#join-addr) { font-size: 16px; }
.web-viewer #home #home-color { min-width: 44px; min-height: 44px; }
.web-viewer #home #pwa-install { order: 7; align-self: start; color: var(--text-hi); border-radius: 13px; padding-inline: 16px; }
.web-viewer #pwa-offline { margin: 0; color: var(--text); font-size: 14px; order: 2; }
.web-viewer #pwa-update {
  position: fixed; z-index: 81; inset: calc(var(--web-top, 0px) + var(--edge-top) + 8px) max(12px, var(--edge-right)) auto auto;
  max-width: calc(100% - max(12px, var(--edge-right)) - max(12px, var(--edge-left))); border: 0;
  border-radius: 13px; padding: 8px 14px; background: var(--blurple); color: var(--on-primary); box-shadow: 0 4px 16px #0004;
}
.web-viewer:has(#pwa-update) #home .home-wrap { padding-top: calc(var(--edge-top) + 66px); }
.web-viewer:has(#pwa-update) #main { padding-top: calc(var(--edge-top) + 60px); }
.web-viewer[data-web-keyboard] #pwa-update { display: none; }

/* No tablet a navegação permanece visível; em paisagem curta vai para a direita. */
.web-viewer #main {
  height: 100%; min-width: 0; max-width: 100%; gap: 0;
  padding: var(--edge-top) var(--edge-right) calc(var(--nav-h) + var(--edge-bottom)) var(--edge-left);
}
.web-viewer #main > :is(#sidebar, #call, #chat) {
  flex: 1 1 100%; width: 100% !important; min-width: 0 !important; min-height: 0; max-width: none;
  margin: 0; border-radius: 0; box-shadow: none;
}
.web-viewer #main[data-mobile-pane=call] > :is(#sidebar, #chat),
.web-viewer #main[data-mobile-pane=sidebar] > :is(#call, #chat),
.web-viewer #main[data-mobile-pane=chat] > :is(#sidebar, #call),
.web-viewer :is(#rail, .splitter, #sidebar-toggle, #btn-chat-toggle, .right-close) { display: none; }
.web-viewer #web-nav:not(.hidden) {
  position: absolute; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px;
  inset: auto 0 0; height: calc(var(--nav-h) + var(--edge-bottom));
  padding: 5px max(12px, var(--edge-right)) calc(5px + var(--edge-bottom)) max(12px, var(--edge-left));
  background: var(--bg-side); border-top: 1px solid var(--line);
}
.web-viewer #web-nav button {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px;
  border: 0; border-radius: 13px; background: transparent; color: var(--text); font: 650 12px Figtree, system-ui, sans-serif;
}
.web-viewer #web-nav button[aria-current] { background: var(--active); color: var(--link); }
.web-viewer[data-web-keyboard] #web-nav { visibility: hidden; }
.web-viewer[data-web-keyboard] #main { padding-bottom: 0; }
.web-viewer .pane-header { height: auto; min-height: 54px; padding: 8px 16px; flex: none; }
.web-viewer .pane-heading { min-width: 0; }
.web-viewer .pane-heading > span:first-child { font-size: 22px; overflow: hidden; text-overflow: ellipsis; }
.web-viewer #sidebar { overflow: hidden; padding: 8px 12px 0; }
.web-viewer #sidebar #channels { min-height: 0; padding-bottom: 10px; mask-image: none; }
/* Os temas compactam essas linhas no PC; no navegador o alvo é a linha toda. */
html[data-tk] .web-viewer #main #sidebar :is(#room-header, #up-user, #btn-invite, .nsb-ib, .cat-add, .channel, .vu, .ou, .friend-row) {
  min-width: 44px; min-height: 44px;
}
html[data-tk] .web-viewer #main #sidebar :is(.cat-add, .ch-edit) { min-width: 44px; min-height: 44px; opacity: 1; }
html[data-tk] .web-viewer #main #sidebar .nsb-sec:has(.cat-add:not(.hidden):not([hidden])) { min-height: 44px; }
.web-viewer #room-menu, .web-viewer #ctx-menu {
  max-width: calc(100% - max(8px, var(--edge-left)) - max(8px, var(--edge-right)));
  max-height: min(70dvh, 32rem); overflow: auto;
}
.web-viewer #away-pill { right: max(16px, var(--edge-right)); bottom: max(12px, var(--edge-bottom)); }
.web-viewer #toasts { right: max(12px, var(--edge-right)); bottom: calc(var(--edge-bottom) + var(--nav-h) + 12px); max-width: calc(100% - 24px); }

/* Voz: rostos redondos. A live mantém a proporção do vídeo. */
.web-viewer #call { overflow: hidden; }
.web-viewer #call-stage { flex: 1 1 0; min-height: 0; min-width: 0; padding: 8px 12px; overflow: auto; }
.web-viewer #call-stage:has(.focus-main .is-screen) { overflow: hidden; }
.web-viewer #call #call-stage .grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(128px, 48%), 1fr)); gap: 8px;
  flex: 0 0 auto; width: min(100%, 560px); height: auto; max-width: 100%; margin: auto; align-content: start;
}
.web-viewer #call #call-stage :is(.grid, .focus-strip) > .tile.is-voice { min-height: 90px; height: auto; width: auto; aspect-ratio: auto; padding: 12px 4px; }
.web-viewer #call #call-stage .tile.is-voice:has(button.watch-chip) { padding-top: 48px; }
.web-viewer #call #call-stage .tile[role=button] { cursor: pointer; }
.web-viewer #call #call-stage .tile .label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.web-viewer #call #call-stage .call-empty { width: min(100%, 38rem); min-height: 0; margin: auto; }
.web-viewer #call .vc-card { min-width: 0; overflow-wrap: anywhere; }
.web-viewer #call .vc-card .vc-join { min-height: 44px; }
.web-viewer #call #call-controls { flex: none; margin: 5px auto 8px; gap: 5px; padding: 4px 7px; backdrop-filter: none; }
.web-viewer #call #call-controls .cc-btn { min-width: 44px; min-height: 44px; }
.web-viewer #call #call-controls #cc-leave { margin-left: 0; }
.web-viewer #call #call-controls .cc-sep { margin-inline: 1px; }
.web-viewer #call #call-controls .cc-btn:active { transform: none; }
.web-viewer #call .pane-header { justify-content: space-between; }
.web-viewer #call #web-audio-options { min-width: 44px; min-height: 44px; color: var(--muted); }
.web-viewer #modal-root #mobile-tools { display: grid; margin: 0; padding: 0; border: 0; background: none; }
.web-viewer #modal-root #mobile-tools .mobile-actions button { min-height: 44px; }
.web-viewer .m-person button, .web-viewer #web-device-select {
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-input); color: var(--text-hi); padding: 6px 10px;
}
.web-viewer #mobile-hint { margin: 6px 0; }
.web-viewer #web-audio-status { align-self: center; flex: none; margin: 4px; }
.web-viewer #call .tile button.watch-chip { min-height: 44px; padding: 6px 11px; }
.web-viewer #call .tile .tile-tools:has(button.watch-chip) { right: 0; top: 0; }
.web-viewer #call .focus-wrap { flex: 1; min-height: 0; width: 100%; max-width: 100%; }
.web-viewer #call .focus-strip { --strip-h: 82px; flex: none; max-width: 100%; }
.web-viewer #call .focus-strip > .tile.is-voice { flex-basis: 106px; }
.web-viewer #call :is(#participants-toggle, #pips:empty) { display: none; }
.web-viewer #call #pips { max-width: min(180px, 36%); }
.web-viewer #call #pips .tile { min-height: 0; }
html .web-viewer #call #pips .tile.is-screen { width: 100% !important; }
.web-viewer #call .tile.is-screen .tile-tools { gap: 4px; padding: 3px; min-width: 0; border-radius: 15px; flex-wrap: wrap; justify-content: center; }
/* A miniatura do PC usa 28px com !important. No toque ela também abre a tela cheia. */
html .web-viewer #call #pips .tile.is-screen .tile-tools button[data-full] { min-width: 44px !important; min-height: 44px !important; }
html .web-viewer #call .tile.is-screen:not(:fullscreen) .tile-tools button,
html.glass .web-viewer #call .tile.is-screen:not(:fullscreen) .tile-tools button { min-width: 44px; min-height: 44px; }
html .web-viewer #call .tile.is-screen .tile-tools button { min-width: 44px; min-height: 44px; }
.web-viewer #call .tile.is-screen .tile-tools :is(.streamer-name, .live-exit-label, .live-mic-name) { display: none; }
.web-viewer #call .tile.is-screen:not(:fullscreen) .tile-tools { opacity: 1; pointer-events: auto; bottom: 6px; }
html .web-viewer #call .tile.is-screen .live-volume { min-height: 44px; }
html .web-viewer #call .tile.is-screen .live-volume input {
  appearance: auto !important; min-height: 44px; height: 44px !important;
  background: transparent !important; accent-color: #fff;
}
.web-viewer #call .tile.is-screen:not(:fullscreen) .live-volume input { width: 62px; }
.web-viewer #call .tile.is-screen:fullscreen .tile-tools {
  bottom: calc(var(--edge-bottom) + 8px); max-width: calc(100% - max(12px, var(--edge-left)) - max(12px, var(--edge-right)));
}
.web-viewer #call .tile.is-screen:fullscreen .live-meta { inset: calc(var(--edge-top) + 6px) max(8px, var(--edge-right)) auto max(8px, var(--edge-left)); }
.web-viewer #call .tile.is-screen:fullscreen .live-meta .live-people { display: none; }
.web-viewer #call .tile.is-screen:fullscreen .live-back { min-width: 44px; min-height: 44px; }

/* O corpo não rola; histórico e campos ficam acima do teclado. */
.web-viewer #chat { overflow: hidden; }
.web-viewer #chat .right-nav { flex: none; padding: 6px 12px; }
.web-viewer #chat .right-nav button { min-height: 44px; }
.web-viewer #chat #chat-online { min-width: 0; }
.web-viewer #btn-chat-search { width: 44px; height: 44px; }
.web-viewer .chat-search-dialog .icon-btn { min-width: 44px; min-height: 44px; }
.web-viewer #modal-root .chat-search-dialog .chat-search-body { overflow: hidden; }
.web-viewer #chat .pane-heading { min-width: 0; }
.web-viewer #chat-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 430px) { .web-viewer #chat-online .co-label { display: none; } }
.web-viewer #chat #messages { flex: 1 1 0; min-height: 0; overflow: hidden auto; }
.web-viewer #chat #composer { flex: none; margin: 4px 10px 8px; padding: 0; min-width: 0; }
.web-viewer #chat #composer #input { min-width: 44px; min-height: 44px; max-height: min(110px, 24dvh); font-size: 16px; }
.web-viewer #chat #composer .composer-row { min-width: 0; padding: 2px 3px; gap: 4px; }
.web-viewer #chat #composer :is(#btn-send, #btn-attach) { min-width: 44px; min-height: 44px; }
.web-viewer #chat :is(.msg, .text, code) { overflow-wrap: anywhere; max-width: 100%; min-width: 0; }
.web-viewer #chat .att-file .att-dl, .web-viewer .lightbox-download { min-width: 44px; min-height: 44px; }
.web-viewer #chat .att-file .fn { display: block; max-width: 100%; }
.web-viewer .lightbox-download { padding-inline: 16px; }
.web-viewer #chat #msg-list .msg { padding-right: 52px; min-height: 44px; }
.web-viewer #chat .msg .msg-web-menu {
  position: absolute; right: 4px; bottom: 0; border: 0; background: transparent; border-radius: 12px; color: var(--muted);
  display: grid; place-items: center; min-width: 44px; min-height: 44px;
}
.web-viewer #ctx-menu .ctx-item { min-height: 44px; }
.web-viewer[data-web-keyboard] #chat :is(.right-nav, .pane-header) { display: none; }

.web-viewer #modal-root .overlay {
  inset: var(--web-top, 0px) 0 auto; height: 100svh; height: var(--web-height, 100dvh);
  align-items: flex-end; padding: max(8px, var(--edge-top)) max(8px, var(--edge-right)) 0 max(8px, var(--edge-left));
}
.web-viewer #modal-root .overlay > .modal {
  width: min(100%, 40rem); min-width: 0; max-height: 100%; min-height: 0;
  border-radius: 24px 24px 0 0; padding-bottom: var(--edge-bottom); overflow: hidden;
  animation: web-sheet-in 150ms var(--ease-out) both;
}
@keyframes web-sheet-in { from { transform: translateY(12px); opacity: 0; } }
html.reduce-motion .web-viewer #modal-root .overlay > .modal { animation: none; }
.web-viewer[data-web-keyboard] #modal-root .overlay > .modal { padding-bottom: 0; }
.web-viewer #modal-root .modal > header { flex: none; align-items: center; gap: 6px; padding: 10px 16px 8px; }
.web-viewer #modal-root .modal > header h2 { font-size: 21px; }
.web-viewer #modal-root .modal > header [data-close] { flex: none; }
.web-viewer #modal-root .modal > .body { min-height: 0; overflow: auto; padding: 10px 16px 16px; overflow-wrap: anywhere; }
.web-viewer #modal-root .modal > footer { flex: none; padding: 8px 16px; }
.web-viewer #modal-root .overlay > .modal.web-settings {
  --settings-inset: 14px; grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
  width: min(100%, 40rem); height: 100%; margin: 0 auto; border-radius: 20px 20px 0 0;
}
.web-viewer #modal-root .web-settings > header { grid-area: 1 / 1; padding-inline: var(--settings-inset); }
.web-viewer #modal-root .web-settings > header h2 { font-size: clamp(22px, 6vw, 28px); }
.web-viewer #modal-root .web-settings > :is(.settings-nav, .body) { grid-area: 2 / 1; padding: 4px var(--settings-inset) 16px; scrollbar-gutter: auto; }
.web-viewer #modal-root .web-settings > footer { grid-area: 3 / 1; padding-inline: var(--settings-inset); }
.web-settings .settings-nav { border: 0; background: transparent; }
.web-settings .settings-nav-items { margin: 0; gap: 0; border: 1px solid var(--line); background: var(--bg-panel); border-radius: 12px; }
.web-settings .settings-nav-items button { min-height: 62px; padding: 10px 12px; font-size: 16px; }
.web-settings .settings-nav-items button + button { border-top: 1px solid var(--line); }
.web-settings .settings-nav-items button > span { flex: 1; min-width: 0; }
.web-settings .settings-nav-items small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.web-settings .settings-row { gap: 8px; grid-template-columns: minmax(0, 1fr) auto; }
.web-settings .settings-row-wide, .web-settings .settings-row:has(:is(input:not([type]), select)) { grid-template-columns: minmax(0, 1fr); }
.web-settings .settings-row:has(:is(input:not([type]), select)) .settings-control { justify-content: stretch; }
.web-settings .settings-control :is(select,input:not([type])) { width: 100%; }
.web-settings .settings-control .btn { max-width: 150px; }
.web-settings .settings-card { padding-inline: 10px; }
.web-viewer #modal-root .web-settings :is(button, summary, select, input, textarea) { min-width: 44px; min-height: 44px; }
.web-viewer #modal-root .web-settings :is(select, input, textarea) { font-size: 16px; }
.web-settings > header .icon-btn { padding: 0; }
.web-viewer .web-theme-sample {
  display: block; height: 24px; border-radius: 7px; border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--sample-bg) 60%, var(--sample-fg) 60% 90%, var(--sample-accent) 90%);
}
.web-viewer .web-settings #web-install { margin-top: 12px; }
.web-viewer .web-settings .web-appearance-status { flex: 1; min-width: 0; margin: 0; font-size: 14px; color: var(--text); }
html.glass .web-viewer #ctx-menu .ctx-row input[type=range] {
  box-sizing: border-box; height: 44px !important; min-height: 44px !important; padding-block: 13px !important;
  background-clip: content-box !important; box-shadow: none;
}
.web-viewer #modal-root .dm-panel #dm-favorite { min-height: 44px; }
.web-viewer .modal #dm-messages { min-height: 64px; max-height: min(36dvh, 16rem); }
.web-viewer .modal .dm-compose textarea { flex: 1; width: 0; }
.web-viewer .modal .dm-compose { position: sticky; bottom: 0; background: var(--bg-main); padding-block: 6px; }
.web-viewer .install-dialog ol { margin: 4px 0 0; padding-left: 23px; }
.web-viewer .install-dialog li { padding: 6px 0; font-size: 16px; line-height: 1.45; }
.web-viewer .m-person { display: flex; flex-direction: column; gap: 8px; }
.web-viewer .m-sheet-head { display: flex; align-items: center; gap: 12px; }
.web-viewer .m-sheet-head .avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background-size: cover; background-position: center; }
.web-viewer .m-sheet-head :is(strong, small) { display: block; }
.web-viewer .m-person label { display: grid; grid-template-columns: 90px minmax(44px,1fr) 44px; gap: 8px; align-items: center; }

@media (orientation: landscape) and (max-height: 560px) {
  .web-viewer #main { padding-right: calc(76px + var(--edge-right)); padding-bottom: var(--edge-bottom); }
  .web-viewer #web-nav:not(.hidden) {
    inset: var(--edge-top) 0 var(--edge-bottom) auto; width: calc(76px + var(--edge-right)); height: auto;
    grid-template: repeat(3, minmax(44px,56px)) / minmax(0,1fr); align-content: center;
    padding: 4px calc(6px + var(--edge-right)) 4px 6px; border-top: 0; border-left: 1px solid var(--line);
  }
  .web-viewer[data-web-keyboard] #main { padding-right: var(--edge-right); }
  .web-viewer #call .focus-strip { display: none; }
  .web-viewer #call-stage { padding-block: 3px; }
  .web-viewer #call .pane-header { min-height: 44px; padding-block: 4px; }
}
@media (max-width: 380px) {
  .web-viewer #call #call-controls #cc-leave span { display: none; }
  .web-viewer #call .tile.is-screen:not(:fullscreen) .live-volume :is(svg, output) { display: none; }
}
@media (hover: none) {
  .web-viewer #home .shelf-arrow { display: none; }
  .web-viewer #home .saved-room-hide { opacity: 1; }
}
