/* Mesa: a coluna Arquivos | Conversas (232 px, recolhível) e a grade livre de até 4 painéis, ilhas com
   8 px de vão; o Modo foco; e, mais abaixo, o que o arquivo e a conversa usam dentro das abas.
   Usa os tokens de tokens.css e o vocabulário da casca (linhas, cartao-n, enviar). */
:root { --nota: rgba(232, 176, 74, .09); --nota-borda: rgba(232, 176, 74, .38); }

.tela.tela-mesa, .casca .tela.tela-mesa { display: flex; flex-direction: column; padding: 8px; overflow: hidden; }
.tela-mesa [hidden] { display: none !important; }
.mesa { position: relative; display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 8px; flex: 1; min-height: 0; }
.mesa.recolhida { grid-template-columns: 0 minmax(0, 1fr); }
.mesa.recolhida .mesa-col { visibility: hidden; border: 0; }
.mesa.redimensionando { -webkit-user-select: none; user-select: none; }
.mesa.redimensionando.vertical { cursor: col-resize; }
.mesa.redimensionando.horizontal { cursor: row-resize; }
.mesa.redimensionando iframe, .mesa.arrastando iframe { pointer-events: none; }

/* ---- botões pequenos comuns ---- */
.icone-btn { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: var(--raio-p); border: 0; background: none; color: var(--muted); transition: background var(--dur), color var(--dur); }
.icone-btn:hover { background: var(--surface-2); color: var(--text); }
.icone-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.icone-btn svg, .mesa svg, .tela-foco svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link { background: none; border: 0; padding: 4px 0; color: var(--muted); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }
.btn-nova { white-space: nowrap; }
.btn-nova { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--signal); color: var(--signal-ink); font-weight: 600; font-size: 14px; text-decoration: none; transition: background var(--dur); }
.btn-nova:hover { background: var(--signal-light); }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 13.5px; font-weight: 500; transition: background var(--dur), color var(--dur); }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }

/* ---- coluna ---- */
.mesa-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid var(--border); border-radius: var(--raio-ilha); background: var(--ilha); overflow: hidden; }
.mesa-recolher { position: absolute; z-index: 4; top: 50%; left: 229px; width: 14px; height: 44px; padding: 0; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 7px; background: var(--ilha-2); color: var(--faint); transform: translateY(-50%); opacity: .55; transition: opacity var(--dur), color var(--dur), border-color var(--dur); }
.mesa-recolher svg { width: 12px; height: 12px; }
.mesa-recolher:hover, .mesa-recolher:focus-visible { opacity: 1; color: var(--text); border-color: var(--signal-border); }
.mesa.recolhida .mesa-recolher { left: -4px; }
.mesa-seg { display: grid; grid-template-columns: 1fr 1fr; margin: 8px 8px 2px; }
.col-arquivos, .col-conversas { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.col-topo, .arv-topo { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.col-topo { flex-direction: row; align-items: center; }
.col-topo .nova { width: 34px; height: 34px; border: 1px solid var(--border); color: var(--soft); }
.arv-busca, .arv-espaco { width: 100%; height: 34px; padding: 0 11px; border-radius: var(--raio-p); border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; }
.arv-busca::placeholder { color: var(--faint); }
.arv-busca:focus, .arv-espaco:focus { outline: none; border-color: var(--signal-border); }
.arv-espaco option { background: var(--ilha-2); }
.arv-linha { display: flex; gap: 8px; align-items: center; }
.arv-ocultos { display: flex; align-items: center; gap: 6px; flex: none; color: var(--muted); font-size: 13px; }
.col-grupos, .arv-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 8px; }
.col-grupo { padding-top: 10px; }
.col-grupo h3 { display: flex; align-items: center; gap: 8px; margin: 0 6px 4px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--faint); }
.col-grupo .cartao-n { min-width: 18px; height: 18px; padding: 0 5px; line-height: 18px; font-size: 11px; }
.col-vazio, .col-mais { margin: 2px 6px 6px; color: var(--faint); font-size: 13px; }
.btn-mais-conversas { margin: 8px 6px 12px; height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--border); background: transparent; color: var(--faint); font-size: 12.5px; }
.btn-mais-conversas:hover:not(:disabled) { color: var(--text); }
.col-rodape { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); }
.col-rodape .link { font-size: 12.5px; }
.col-resumo { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.item-conv { display: flex; align-items: flex-start; gap: 9px; width: 100%; padding: 7px 8px; border: 0; border-radius: 9px; background: none; color: inherit; text-align: left; transition: background var(--dur); }
.item-conv:hover { background: var(--hover); }
.item-conv.aberta { background: var(--surface-2); }
.item-conv.pendente { cursor: default; opacity: .65; }
.item-conv.pendente:hover { background: none; }
.item-ag { width: 22px; height: 22px; flex: none; margin-top: 1px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.item-ag svg { width: 13px; height: 13px; }
.item-conv.rodando .item-ag { color: var(--signal); background: var(--signal-dim); }
.item-conv.rodando .item-ag svg { animation: mesa-girar 2.4s linear infinite; }
.item-conv.pede .item-ag { color: var(--warn); background: var(--warn-dim); }
.item-texto { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.item-linha { display: flex; align-items: baseline; gap: 8px; }
.item-titulo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.item-conv.nova .item-titulo { font-weight: 600; color: var(--text); }
.item-conv.nova .item-tempo { color: var(--signal); }
.item-tempo { flex: none; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.item-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.item-previa { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.4; color: var(--faint); overflow-wrap: anywhere; }
.btn-responder { margin: 0 0 6px 39px; height: 26px; padding: 0 11px; border-radius: 13px; border: 1px solid var(--nota-borda); background: var(--warn-dim); color: var(--warn); font-size: 12.5px; font-weight: 500; }
.btn-responder:hover { background: rgba(232, 176, 74, .2); }
@keyframes mesa-girar { to { transform: rotate(360deg); } }

/* árvore */
.arv-item { display: flex; align-items: center; gap: 4px; width: 100%; min-height: 30px; padding: 4px 8px 4px calc(6px + var(--nivel, 0) * 14px); border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 13.5px; text-align: left; }
.arv-item:hover { background: var(--hover); }
.arv-item.ativo { background: var(--signal-dim); color: var(--signal-light); }
.arv-item.oculto .arv-nome { color: var(--muted); }
.arv-item:disabled { color: var(--faint); cursor: default; }
.arv-seta { width: 16px; height: 16px; flex: none; display: grid; place-items: center; color: var(--faint); transition: transform var(--dur); }
.arv-seta svg { width: 14px; height: 14px; }
.arv-seta.aberta { transform: rotate(90deg); }
.arv-nome { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arv-sub { margin-left: auto; padding-left: 8px; color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.arv-vazio { margin: 6px 8px; padding-left: calc(var(--nivel, 0) * 14px); color: var(--faint); font-size: 13px; }

/* ---- grade ---- */
.mesa-grade { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mesa-volta { display: none; }
/* painéis e divisores ficam soltos na raiz, posicionados em pixels pela Mesa (nada sai do DOM ao dividir) */
.grade-raiz { position: relative; flex: 1; min-width: 0; min-height: 0; }
.grade-raiz > .painel { position: absolute; }
.grade-divisor { position: absolute; z-index: 2; touch-action: none; outline: none; }
.grade-divisor.vertical { cursor: col-resize; }
.grade-divisor.horizontal { cursor: row-resize; }
.grade-divisor::before { content: ''; position: absolute; inset: 0 -4px; }
.grade-divisor.horizontal::before { inset: -4px 0; }
.grade-divisor::after { content: ''; position: absolute; border-radius: 2px; background: transparent; transition: background var(--dur), box-shadow var(--dur); }
.grade-divisor.vertical::after { top: 50%; left: 3px; width: 2px; height: 44px; transform: translateY(-50%); }
.grade-divisor.horizontal::after { left: 50%; top: 3px; height: 2px; width: 44px; transform: translateX(-50%); }
.grade-divisor:hover::after, .grade-divisor:focus-visible::after, .grade-divisor:active::after { background: var(--signal); box-shadow: 0 0 10px var(--glow); }

/* ---- painéis ---- */
.icone-btn:disabled { opacity: .3; cursor: default; background: none; }
.painel { container-type: inline-size; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 1px solid var(--border); border-radius: var(--raio-ilha); background: var(--ilha); overflow: hidden; transition: border-color var(--dur); }
.painel.ativo:not(.so) { border-color: var(--border-2); }
.painel-barra { display: flex; align-items: center; gap: 6px; flex: none; height: 42px; padding: 0 6px 0 7px; border-bottom: 1px solid var(--border); }
.painel-abas { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; height: 100%; overflow-x: auto; scrollbar-width: none; }
.painel-abas::-webkit-scrollbar { display: none; }
.painel-acoes { display: flex; align-items: center; flex: none; }
.painel-acoes .icone-btn { width: 28px; height: 28px; border-radius: 7px; }
.painel-acoes .icone-btn svg { width: 15px; height: 15px; }
.aba { display: flex; align-items: center; flex: none; max-width: 220px; height: 28px; border-radius: 8px; color: var(--muted); transition: background var(--dur), color var(--dur); }
.aba:hover { background: var(--hover); color: var(--text-2); }
.aba.ativa { background: var(--surface-2); color: var(--text); }
.painel.ativo:not(.so) .aba.ativa { box-shadow: inset 0 -1.5px 0 var(--signal); }
.aba-botao { display: flex; align-items: center; gap: 7px; min-width: 0; height: 100%; padding: 0 2px 0 9px; border: 0; background: none; color: inherit; font-size: 13px; font-weight: 500; }
.aba-botao svg { width: 14px; height: 14px; flex: none; }
.aba-titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aba-mono { flex: none; padding: 2px 5px; border-radius: 4px; background: var(--surface-2); color: var(--faint); font: 10.5px/1 var(--font-mono); }
.aba.rodando .aba-botao svg { color: var(--signal); animation: mesa-girar 2.4s linear infinite; }
.aba.pede .aba-botao svg { color: var(--warn); }
.aba.sumida .aba-titulo { color: var(--faint); text-decoration: line-through; }
.aba-x { width: 22px; height: 22px; margin-right: 3px; flex: none; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--faint); opacity: 0; transition: opacity var(--dur), background var(--dur); }
.aba:hover .aba-x, .aba.ativa .aba-x, .aba-x:focus-visible { opacity: 1; }
.aba-x:hover { background: var(--surface-3); color: var(--text); }
.aba-x svg { width: 12px; height: 12px; }
@media (hover: none) { .aba-x { opacity: 1; } }
/* painel estreito: as ações cedem lugar às abas (ficam no ⋯ e no menu da aba) */
@container (max-width: 420px) { .painel-acoes [data-acao="link"], .painel-acoes [data-acao="fora"], .painel-acoes [data-acao="atualizar"] { display: none; } }
@container (max-width: 260px) { .painel-acoes [data-acao="nova"] { display: none; } .aba { max-width: 140px; } }
.painel-corpo { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.aba-conteudo { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.painel-zona { position: absolute; inset: 6px; z-index: 5; border: 1.5px dashed var(--signal); border-radius: 10px; background: var(--signal-dim); box-shadow: inset 0 0 24px var(--glow); pointer-events: none; transition: left .12s var(--ease), top .12s var(--ease); }
.painel-zona[data-lado="direita"] { left: 50%; }
.painel-zona[data-lado="baixo"] { top: 50%; }
.painel-vazio, .aba-nota { margin: auto; max-width: 340px; padding: 24px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.painel-vazio p, .aba-nota p { margin: 0 0 14px; }
.aba-nota .aba-nota-tit { margin-bottom: 4px; color: var(--text); font-size: 15px; font-weight: 600; }
.btn-borda { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 16px; border: 1px solid var(--border-2); background: none; color: var(--text); font-size: 13.5px; text-decoration: none; }
.btn-borda:hover { background: var(--surface-2); }
.nova-vazia { margin: auto; width: min(560px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 12px; }
.nova-vazia h2 { margin: 0; text-align: center; font-size: 17px; font-weight: 600; }
.nova-vazia .comp { margin: 0; }
.nova-dica { padding-left: 6px; font-size: 12px; color: var(--faint); }
.nova-erro { margin: 0; color: var(--danger-text); font-size: 13.5px; text-align: center; }
.nova-erro:empty { display: none; }

/* ---- modo foco ---- */
.tela.tela-foco { padding: 8px; }
.foco-corpo { border: 1px solid var(--border); border-radius: var(--raio-ilha); background: var(--ilha); overflow: hidden; }

/* ---- arquivo ---- */
.arq-barra { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.arq-caminho { display: flex; align-items: baseline; gap: 2px; min-width: 0; flex: 1 1 220px; font-size: 13.5px; white-space: nowrap; overflow: hidden; }
.arq-caminho span { color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
.arq-caminho b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.arq-sujo { margin-left: 8px; font-style: normal; font-size: 12px; color: var(--warn); }
.arq-acoes { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.btn-salvar { height: 32px; padding: 0 14px; border: 0; border-radius: 16px; background: var(--signal); color: var(--signal-ink); font-weight: 600; font-size: 13.5px; }
.btn-salvar:disabled { background: var(--surface-3); color: var(--muted); cursor: default; }
.arq-aviso { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); background: var(--signal-dim); color: var(--text-2); }
.arq-aviso.atencao { background: var(--nota); }
.arq-aviso.erro { background: rgba(224, 122, 95, .12); }
.arq-aviso span { flex: 1; min-width: 200px; }
.arq-aviso button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; }
.arq-aviso button:hover { background: var(--surface-3); }
.arq { container-type: inline-size; }
.arq-meio { position: relative; flex: 1; min-height: 0; display: flex; }
.arq-corpo { flex: 1; min-width: 0; overflow: auto; display: flex; flex-direction: column; }
.arq-nota { margin: 20px; color: var(--muted); font-size: 14.5px; }
.arq-nota a { color: var(--signal); }
.arq-codigo { margin: 0; padding: 16px 18px; font: 13px/1.6 var(--font-mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.arq-editor { flex: 1; width: 100%; min-height: 300px; padding: 16px 18px; border: 0; background: rgba(0, 0, 0, .35); resize: none; font: 13.5px/1.6 var(--font-mono); color: var(--text); tab-size: 2; }
.arq-editor:focus { outline: none; box-shadow: inset 0 0 0 1px var(--signal-border); }
.arq-iframe { flex: 1; width: 100%; min-height: 360px; border: 0; background: #fff; }
.arq-centro { flex: 1; display: grid; place-items: center; padding: 20px; }
.arq-centro img, .arq-centro video { max-width: 100%; max-height: 70vh; }
.arq-versao { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: linear-gradient(var(--warn-dim), var(--warn-dim)), var(--ilha-2); border-bottom: 1px solid var(--nota-borda); font-size: 13.5px; }
.arq-versao span { flex: 1; min-width: 180px; color: var(--text-2); }
.arq-versao button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; }
.arq-versao button:hover { background: var(--surface-3); }
.arq-historico { width: 280px; flex: none; overflow-y: auto; padding: 14px 14px 20px; border-left: 1px solid var(--border); background: rgba(255, 255, 255, .02); }
.arq-historico h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.hist-ultima { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.hist-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.hist-lista li { display: flex; gap: 10px; padding: 8px; border-radius: var(--raio-p); }
.hist-lista li.ativo { background: var(--nota); }
.hist-lista li div { min-width: 0; font-size: 13.5px; }
.hist-lista time { color: var(--faint); font-size: 12.5px; margin-left: 4px; }
.hist-lista p { margin: 2px 0 2px; color: var(--soft); overflow-wrap: anywhere; }
.hist-lista .link { font-size: 13px; padding: 2px 0; }

/* markdown */
.md { padding: 18px 22px 28px; max-width: 78ch; color: var(--text-2); font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-texto.md { padding: 0; max-width: none; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.3em 0 .5em; line-height: 1.25; color: var(--text); letter-spacing: -.01em; font-weight: 600; }
.md h1 { font-size: 24px; } .md h2 { font-size: 20px; } .md h3 { font-size: 17px; } .md h4, .md h5, .md h6 { font-size: 15px; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .md-tabela { margin: 0 0 .8em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md li.n1 { margin-left: 1.2em; } .md li.n2 { margin-left: 2.4em; } .md li.n3 { margin-left: 3.6em; }
.md a { color: var(--signal-light); }
.md code { font: .88em var(--font-mono); padding: .1em .35em; border-radius: 4px; background: var(--surface-2); }
.md pre { padding: 12px 14px; border-radius: var(--raio-p); background: rgba(0, 0, 0, .4); border: 1px solid var(--border); overflow-x: auto; }
.md pre code { padding: 0; background: none; font-size: 12.5px; line-height: 1.55; }
.md blockquote { padding-left: 14px; border-left: 2px solid var(--border-2); color: var(--soft); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md img { max-width: 100%; }
.md-tabela { overflow-x: auto; }
.md-tabela table { border-collapse: collapse; font-size: 13.5px; }
.md-tabela th, .md-tabela td { padding: 6px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md-tabela th { color: var(--muted); font-weight: 600; }
.md-caixa { font-family: var(--font-mono); color: var(--muted); }
.arq-corpo > .md-tabela { padding: 12px 16px; }

/* ---- conversa ---- */
.conv-cab { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.conv-tit { min-width: 0; flex: 1 1 160px; } /* sem 160px de título ao lado, as ações descem para a linha de baixo (painel estreito, celular) */
.conv-tit h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.conv-meta .estado { display: inline-flex; align-items: center; gap: 6px; color: var(--signal-light); }
.conv-meta .estado i { width: 7px; height: 7px; border-radius: 50%; background: var(--signal); animation: pulso 1.6s ease-in-out infinite; }
.conv-meta .estado.esperando-permissao { color: var(--warn); }
.conv-meta .estado.esperando-permissao i { background: var(--warn); }
.conv-acoes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.alternar, .btn-parar { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border-2); background: none; color: var(--soft); font-size: 13px; }
.alternar:hover, .btn-parar:hover { background: var(--surface-2); color: var(--text); }
.btn-parar svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
/* Cabeçalho da conversa: "Só eu vejo" (cadeado) / "Equipe vê" (verde). Sempre com texto: o estado precisa estar à vista. */
.conv-visibilidade svg { width: 14px; height: 14px; flex: none; }
.conv-visibilidade[aria-pressed="true"] { border-color: rgba(48, 220, 104, .35); background: rgba(48, 220, 104, .1); color: var(--signal-light); }
.item-so-eu { display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; vertical-align: -1px; color: var(--faint); }
.item-meta > .item-so-eu:first-child { margin-left: 0; }
.item-so-eu svg { width: 11px; height: 11px; flex: none; }
.conv-faixa { padding: 9px 18px; font-size: 13.5px; color: var(--text-2); background: var(--nota); border-bottom: 1px solid var(--nota-borda); }
.conv-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px 16px; display: flex; flex-direction: column; }
.conv-nota-vazia { margin: auto; color: var(--muted); font-size: 14.5px; text-align: center; max-width: 320px; }

.msg { padding-left: 38px; margin-top: 4px; }
.msg.grupo { margin-top: 18px; }
.msg-cab { display: flex; align-items: center; gap: 10px; margin: 0 0 4px -38px; font-size: 14px; }
.msg-cab b { font-weight: 600; }
.msg-cab time { color: var(--faint); font-size: 12.5px; }
.avatar { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--text); font-size: 13px; font-weight: 600; }
.avatar.eu { background: rgba(48, 220, 104, .16); color: var(--signal-light); }
.avatar.claude { background: var(--text); color: var(--bg); }
.msg-texto { font-size: 15px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-texto.md { white-space: normal; }
.msg-sit { margin: 4px 0 0; font-size: 12.5px; color: var(--faint); }
.msg-sistema { margin: 16px 0 4px; text-align: center; font-size: 13px; color: var(--faint); }
.msg-erro { margin: 14px 0 4px 38px; padding: 8px 12px; border-radius: var(--raio-p); background: rgba(224, 122, 95, .1); color: var(--danger-text); font-size: 14px; }

.passo { margin: 6px 0; border-radius: var(--raio-p); background: var(--surface); border: 1px solid var(--border); }
.passo summary { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 10px; cursor: pointer; list-style: none; font-size: 13.5px; color: var(--soft); }
.passo summary::-webkit-details-marker { display: none; }
.passo summary svg { width: 14px; height: 14px; flex: none; color: var(--faint); transition: transform var(--dur); }
.passo[open] summary svg { transform: rotate(90deg); }
.passo summary b { font-weight: 600; color: var(--text-2); flex: none; }
.passo summary code { min-width: 0; flex: 1; font: 12.5px var(--font-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.passo-sit { flex: none; font-size: 12px; color: var(--faint); }
.passo-sit.erro { color: var(--danger-text); }
.passo-corpo { padding: 2px 12px 12px; }
.passo-rot { margin: 8px 0 4px; font-size: 12.5px; color: var(--muted); }
.passo pre, .cartao-perm pre { margin: 0; max-height: 320px; overflow: auto; padding: 10px 12px; border-radius: 6px; background: rgba(0, 0, 0, .4); font: 12.5px/1.5 var(--font-mono); color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

.cartao-perm { margin: 8px 0; padding: 14px 16px; border-radius: var(--raio); border: 1px solid var(--nota-borda); background: var(--nota); }
.cartao-perm:not(.pendente) { border-color: var(--border); background: var(--surface); }
.perm-tit { margin: 0; font-size: 14.5px; color: var(--text); }
.perm-resumo { margin: 6px 0 0; }
.perm-resumo code { font: 13px var(--font-mono); color: var(--text-2); overflow-wrap: anywhere; }
.cartao-perm details { margin-top: 10px; }
.cartao-perm summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.perm-botoes { display: flex; gap: 8px; margin-top: 12px; }
.perm-botoes button { height: 38px; padding: 0 18px; border-radius: 19px; font-weight: 600; font-size: 14px; }
.perm-botoes .aprovar { border: 0; background: var(--signal); color: var(--signal-ink); }
.perm-botoes .aprovar:hover { background: var(--signal-light); }
.perm-botoes .negar { border: 1px solid var(--border-2); background: none; color: var(--text); }
.perm-botoes .negar:hover { background: var(--surface-2); }
.perm-botoes button:disabled { opacity: .5; cursor: progress; }
.perm-fim { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }

.nota { align-self: flex-end; max-width: min(520px, 92%); margin: 16px 0 4px; padding: 10px 14px 12px; border-radius: var(--raio); border: 1px solid var(--nota-borda); background: var(--nota); }
.nota-cab { display: flex; gap: 4px; align-items: baseline; margin: 0 0 4px; font-size: 12.5px; color: var(--warn); }
.nota-cab span { font-weight: 600; }
.nota-cab time { margin-left: auto; padding-left: 10px; color: var(--faint); }
.nota-texto { margin: 0; font-size: 15px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.nota button { margin-top: 8px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--nota-borda); background: rgba(0, 0, 0, .25); color: var(--text); font-size: 13px; }
.nota button:hover { background: rgba(232, 176, 74, .18); }
.nota-fim { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

.trabalhando { display: flex; align-items: center; gap: 5px; margin: 14px 0 0 38px; color: var(--muted); font-size: 13px; }
.trabalhando i { width: 6px; height: 6px; border-radius: 50%; background: var(--signal); animation: pulso 1.2s ease-in-out infinite; }
.trabalhando i:nth-child(2) { animation-delay: .2s; }
.trabalhando i:nth-child(3) { animation-delay: .4s; }
.trabalhando span { margin-left: 6px; }

/* compositor da conversa */
.comp { margin: 0 12px 12px; border-radius: 14px; border: 1px solid var(--border-2); background: var(--ilha-2); transition: border-color var(--dur), background var(--dur); }
.comp:focus-within { border-color: var(--signal-border); }
.comp textarea { display: block; width: 100%; min-height: 56px; max-height: 40vh; padding: 12px 14px 4px; border: 0; background: none; resize: vertical; font-size: 15px; line-height: 1.5; }
.comp textarea::placeholder { color: var(--faint); }
.comp textarea:focus { outline: none; }
.comp-rodape { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 8px 10px; }
.enviar-redondo { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--signal); color: var(--signal-ink); transition: background var(--dur), transform var(--dur) var(--ease); }
.enviar-redondo:hover { background: var(--signal-light); }
.enviar-redondo:active { transform: scale(.94); }
.enviar-redondo:disabled { opacity: .5; cursor: progress; }
.enviar-redondo svg { width: 18px; height: 18px; stroke-width: 2.2; }

/* ---- menu da árvore, pedido de nome ---- */
.arv-linha-item { position: relative; }
.arv-linha-item .arv-item { padding-right: 32px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.arv-mais { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); opacity: 0; transition: opacity var(--dur), background var(--dur); }
.arv-mais svg { width: 16px; height: 16px; fill: currentColor; }
.arv-linha-item:hover .arv-mais, .arv-mais:focus-visible, .arv-mais[aria-expanded="true"] { opacity: 1; }
.arv-mais:hover { background: var(--surface-3); color: var(--text); }
@media (hover: none) { .arv-mais { opacity: .6; } }
.menu-ctx { position: fixed; z-index: 60; min-width: 220px; padding: 6px; border-radius: var(--raio); border: 1px solid var(--border-2); background: var(--ilha-2); box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 0 1px rgba(48, 220, 104, .04); }
.menu-ctx button { display: block; width: 100%; min-height: 34px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--text-2); font-size: 14px; text-align: left; }
.menu-ctx button:hover, .menu-ctx button:focus-visible { background: var(--signal-dim); color: var(--signal-light); outline: none; }
.menu-ctx hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--border); }
.dlg-nome { width: min(380px, calc(100vw - 32px)); padding: 20px; border-radius: var(--raio); border: 1px solid var(--border-2); background: var(--ilha-2); color: var(--text); box-shadow: 0 24px 70px rgba(0, 0, 0, .7); }
.dlg-nome::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-nome h3 { margin: 0 0 14px; font-size: 16px; font-weight: 600; }
.dlg-nome label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.dlg-nome input { height: 40px; padding: 0 12px; border-radius: var(--raio-p); border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-size: 16px; }
.dlg-nome input:focus { outline: none; border-color: var(--signal-border); box-shadow: 0 0 0 3px var(--glow); }
.dlg-botoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-botoes button { height: 36px; padding: 0 16px; border-radius: 18px; border: 1px solid var(--border-2); background: var(--surface); font-size: 14px; }
.dlg-botoes button:hover { background: var(--surface-3); }
.dlg-botoes .ok { border-color: var(--signal); background: var(--signal); color: var(--signal-ink); font-weight: 600; }
.dlg-botoes .ok:hover { background: var(--signal-light); }

/* ---- diff de uma versão ---- */
.hist-acoes { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 2px; }
.hist-diff-topo { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hist-diff-topo .icone-btn { width: 32px; height: 32px; }
.hist-diff-topo b { font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.hist-diff-msg { margin: 0 0 2px; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.hist-diff-quem { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.btn-hist { height: 30px; padding: 0 12px; margin-bottom: 12px; border-radius: 15px; border: 1px solid var(--border-2); background: var(--surface); font-size: 13px; }
.btn-hist:hover { background: var(--surface-3); }
.hist-diff { margin: 0 -14px -20px; border-top: 1px solid var(--border); }
.diff { margin: 0; padding: 6px 0 14px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; }
.diff-l { display: block; padding: 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--soft); }
.diff-l.mais { background: rgba(48, 220, 104, .14); color: var(--signal-light); box-shadow: inset 2px 0 0 var(--signal); }
.diff-l.menos { background: rgba(224, 122, 95, .15); color: var(--danger-text); box-shadow: inset 2px 0 0 var(--danger); }
.diff-l.trecho { margin: 6px 0; color: var(--faint); font-size: 11.5px; }

/* ---- larguras ---- */
@media (max-width: 1280px) { .arq-historico { width: 240px; } }
/* painel estreito: o histórico flutua sobre o arquivo em vez de espremer */
@container (max-width: 640px) {
  .arq-historico { position: absolute; right: 0; top: 0; bottom: 0; z-index: 2; width: min(280px, 86%); background: var(--ilha-2); box-shadow: -12px 0 30px rgba(0, 0, 0, .5); }
}
/* celular: um painel por vez, com a barra de abas no topo; a coluna e a grade se revezam */
@media (max-width: 767px) {
  .tela.tela-mesa, .casca .tela.tela-mesa { padding: 0 8px 8px; }
  .mesa, .mesa.recolhida { grid-template-columns: minmax(0, 1fr); }
  .mesa.recolhida .mesa-col { visibility: visible; border: 1px solid var(--border); }
  .mesa-recolher { display: none; }
  .mesa[data-movel="lista"] .mesa-grade, .mesa[data-movel="painel"] .mesa-col { display: none; }
  .mesa-volta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
  .mesa-volta [data-voltar] { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 8px 0 2px; border: 0; background: none; color: var(--soft); font-size: 14px; }
  .mesa-volta [data-voltar] svg { width: 18px; height: 18px; }
  .mesa-trocapainel { display: flex; gap: 4px; }
  .mesa-trocapainel button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: none; color: var(--muted); font-size: 13px; font-weight: 600; }
  .mesa-trocapainel button[aria-pressed="true"] { border-color: var(--signal-border); background: var(--signal-dim); color: var(--signal-light); }
  .painel-barra { height: 46px; }
  .painel-acoes [data-acao="link"], .painel-acoes [data-acao="fora"] { display: none; }
  .painel-acoes .icone-btn { width: 36px; height: 36px; }
  .aba { height: 34px; max-width: 200px; }
  .aba-x { width: 28px; height: 28px; }
  .tela.tela-foco { padding: 0; }
  .foco-corpo { border-radius: 0; border: 0; }
  .item-conv { padding: 9px 8px; }
  .conv-cab { padding: 10px 10px 8px 14px; }
  .conv-lista { padding: 6px 12px 12px; }
  .msg { padding-left: 0; }
  .msg-cab { margin-left: 0; }
  .msg-erro, .trabalhando { margin-left: 0; }
  .comp { margin: 0 6px 6px; }
  .comp textarea { font-size: 16px; }
  .comp-rodape { flex-direction: column; align-items: stretch; }
  .nova-vazia .comp-rodape { flex-direction: row; align-items: center; }
  .arq-barra { padding-left: 12px; }
  .arv-busca, .arv-espaco { font-size: 16px; height: 40px; }
  .arv-item { min-height: 40px; }
  .arv-mais { width: 40px; height: 40px; right: 0; }
  .arv-linha-item .arv-item { padding-right: 40px; }
}
