/* A página que um bot mostra na conversa (show_page). Só tokens da biblioteca. A largura é a da coluna larga da
   referência (medida conferida no código de lá): o menor entre a coluna, 70% (no mínimo 720 px) e 1200 px. */
.hb.app .app-page {
  align-self: flex-start;
  width: min(100%, max(720px, 70%), 1200px);
  min-width: 0;
}
.pg {
  position: relative;
  min-width: 0;
  /* O quadro só entra depois do documento: a caixa já tem a altura dele, e nada muda de tamanho entre os estados. */
  height: var(--pg-h, 240px);
}
.pg-frame {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
}
.pg[data-state='loading'] .pg-frame,
.pg[data-state='failed'] .pg-frame,
.pg[data-state='gone'] .pg-frame {
  visibility: hidden;
}
.pg-load {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.pg-load[hidden],
.pg-note[hidden] {
  display: none;
}
/* A faixa de falha fica no lugar do quadro, na mesma altura: nada muda de tamanho entre os estados. */
.pg-note {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  overflow: hidden;
}
.pg[data-state='failed'] .pg-note {
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
  background: var(--red-soft);
  color: var(--text);
}

/* Botões do canto, tela cheia e painel (rodada N15). Medidas do app de referência: botões de 32 px com ícone de 12 px, a 8 px
   do canto e 4 px entre si; tela cheia com 24 px de margem, cartão de até 1100 px e barra de título de 15 px. O resto é
   leiaute nosso. */
.pg-surface {
  display: contents;
}

/* A caixa só vai para a camada de cima na tela cheia; fechada, volta a ser um bloco comum da conversa. */
.pg[popover]:not(:popover-open) {
  display: block;
  position: relative;
  inset: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  overflow: visible;
  width: auto;
  box-sizing: border-box;
  min-width: 0;
  height: var(--pg-h, 240px);
}
.pg-fill,
.pg-fill .pg-frame {
  height: 100%;
}

.pg-acts {
  position: absolute;
  inset: 8px 8px auto auto;
  z-index: 1;
  display: inline-flex;
  gap: 4px;
}
.pg-acts[hidden] {
  display: none;
}
/* Só onde há ponteiro de verdade os botões ficam escondidos até o ponteiro ou o foco chegar; em tela de toque, sempre. */
@media (hover: hover) {
  .pg:not(:hover, :focus-within) > .pg-acts {
    opacity: 0;
  }
}
.pg-b {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 32px;
  block-size: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.pg-b:hover {
  background: var(--surface-3);
}
.pg-b:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
}

.pg-bar {
  display: none;
}
.pg-bar-t {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pg-b-bar {
  background: none;
  color: var(--text-3);
}
.pg-b-bar:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Tela cheia: a caixa cobre a janela, e o cartão (barra do app + quadro) fica no meio. */
.pg:popover-open {
  box-sizing: border-box;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  max-inline-size: none;
  max-block-size: none;
  margin: 0;
  padding: 24px;
  display: flex;
  justify-content: center;
  border: 0;
  overflow: hidden;
  color: var(--text);
  background: color-mix(in srgb, var(--overlay) 30%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.pg:popover-open::backdrop {
  background: none;
}
.pg:popover-open > .pg-acts {
  display: none;
}
.pg:popover-open > .pg-surface {
  position: relative;
  display: flex;
  flex: 0 1 1100px;
  min-inline-size: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: calc(var(--r-lg) * 2);
  background: var(--hb-card);
  box-shadow: 0 0 0 1px var(--hb-line);
}
.pg:popover-open .pg-bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--hb-line);
}
.pg:popover-open .pg-frame {
  flex: 1 1 0;
  min-block-size: 0;
  block-size: auto !important;
  background: var(--hb-side);
}

/* O visualizador aberto por uma página: o botão de baixar some e uma nota diz de onde veio a imagem. */
.hb.app .vw-b[hidden],
.hb.app .vw-note[hidden] {
  display: none;
}
.hb.app .vw-note {
  margin-inline-start: 8px;
  padding: 1px 8px;
  border: 1px solid var(--hb-line);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

/* A barra de citar (rodada N22): dentro do bloco da página, rente à borda de baixo, só sobre o que é da própria página. Mostra de
   onde vem o trecho, o trecho inteiro e o botão, que só liga depois de o mesmo trecho ficar à vista (veja pagequote.js). */
.pg-quote {
  position: absolute;
  inset-block-end: var(--s-2);
  inset-inline: var(--s-2);
  margin-inline: auto;
  z-index: 22;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  inline-size: min(420px, calc(100% - var(--s-2) * 2)); /* 420: a largura da barra de lá */
  box-sizing: border-box;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}
.pg-quote[hidden] {
  display: none;
}
.pg-quote-l {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}
.pg-quote-t {
  max-block-size: calc(var(--s-2) * 12);
  margin: 0;
  padding-inline-start: 8px;
  overflow: auto;
  border-inline-start: 2px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  line-height: 20px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.pg-quote-b {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--s-2);
  block-size: 28px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.pg-quote-b:disabled {
  color: var(--text-3);
  opacity: 0.55;
  cursor: default;
}
.pg-quote-b:not(:disabled):hover {
  background: var(--hb-hover);
}
.pg-quote-b:focus-visible,
.pg-quote-t:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
}

/* A pergunta antes de abrir um link da página: caixa modal do navegador, no estilo das caixas do app. */
.pg-ask {
  inline-size: min(440px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: calc(var(--r-lg) * 1.5);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.pg-ask::backdrop {
  background: color-mix(in srgb, var(--overlay) 40%, transparent);
}
.pg-ask-h {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}
.pg-ask-p {
  margin: 0 0 12px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 18px;
  overflow-wrap: anywhere;
}
.pg-ask-url {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 18px;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.pg-ask-dim {
  color: var(--text-3);
}
.pg-ask-host {
  color: var(--text);
  font-weight: 700;
}
.pg-ask-warn {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 13px;
  line-height: 18px;
}
.pg-ask a[aria-disabled='true'] {
  opacity: 0.55;
  pointer-events: none;
}
.pg-ask-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
