/* Tessera — tema CLARO, frio e dessaturado (inspirado no Qoves): vidro fosco
   sobre gradiente, linhas finíssimas, muito respiro, botões pretos, acento
   azul-ardósia discreto. Headlines em sans leve. */

:root {
  --text: #292d33;           /* grafite frio, quase preto */
  --muted: #868d95;          /* cinza frio */
  --border: rgba(40, 46, 54, .12);
  --border-strong: rgba(40, 46, 54, .22);
  --hair: rgba(255, 255, 255, .6);   /* brilho da borda de vidro */

  /* vidro */
  --glass: rgba(252, 253, 255, .55);        /* painéis: translúcido o bastante pra mostrar a malha */
  --card-glass: linear-gradient(160deg, rgba(255, 255, 255, .66), rgba(255, 255, 255, .34)); /* cartões */
  --card-glass-hover: linear-gradient(160deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .5));

  --accent: #5f7f96;         /* azul-ardósia dessaturado */
  --accent-soft: rgba(95, 127, 150, .14);

  --btn-dark: #23272d;       /* botões pretos */
  --on-dark: #f4f6f7;

  --ok: #5a8a6a;
  --danger: #b15a52;

  --shadow: 0 1px 2px rgba(40, 46, 54, .04), 0 12px 34px -16px rgba(40, 46, 54, .24);
  --shadow-soft: 0 1px 6px rgba(40, 46, 54, .08);

  --radius: 16px;
  --radius-lg: 24px;
  --radius-sm: 10px;
  font-size: 15px;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; max-width: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh; /* iOS Safari: desconta a barra dinâmica */
  overflow: hidden;
  display: flex;
  flex-direction: row;
  color: var(--text);
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  /* MALHA de gradientes (mesh) — blobs de cor dessaturada que o vidro revela.
     Sem isso, vidro sobre branco fica só branco. */
  background-color: #e7eaee;
  background-image:
    radial-gradient(at 8% 12%, rgba(146, 178, 214, .55), transparent 42%),
    radial-gradient(at 90% 6%, rgba(200, 176, 214, .46), transparent 42%),
    radial-gradient(at 94% 70%, rgba(160, 204, 196, .46), transparent 46%),
    radial-gradient(at 16% 92%, rgba(214, 196, 168, .42), transparent 46%),
    radial-gradient(at 55% 48%, rgba(184, 198, 220, .38), transparent 58%);
  background-attachment: fixed;
}

h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
small { color: var(--muted); }
button { font: inherit; cursor: pointer; color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(40, 46, 54, .18); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(40, 46, 54, .3); background-clip: padding-box; }

/* ---------- layout que colapsa ---------- */
#layout {
  flex: 1; min-width: 0; min-height: 0;
  display: grid; grid-template-columns: 50% 50%;
  transition: grid-template-columns .34s cubic-bezier(.2, 0, 0, 1),
              grid-template-rows .34s cubic-bezier(.2, 0, 0, 1);
}
body.collapsed #layout { grid-template-columns: 100% 0%; }

/* ---------- chat (painel de vidro) ---------- */
#chat {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border-right: 1px solid var(--border);
  position: relative; /* âncora das rebarbas (flutuam no canto sup. esq.) */
}
#chat-head {
  display: flex; align-items: center; gap: 12px; height: 82px; padding: 0 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, .06));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 26px -18px rgba(40, 46, 54, .5);
  position: relative; z-index: 2;
}
#chat-head .brand-mark { color: var(--text); display: block; }
#chat-head h1 { font-size: 17px; font-weight: 500; }
#chat-head small { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; }
.chat-head-spacer { flex: 1; }
.thread-select {
  font: inherit; font-size: 16px; font-weight: 500; color: var(--text);
  background: transparent; border: none; border-radius: 8px; padding: 4px 6px;
  max-width: 200px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.thread-select:hover { background: rgba(40, 46, 54, .05); }
.thread-select:focus { outline: none; background: rgba(40, 46, 54, .06); }
.thread-reset {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1;
  transition: color .15s, border-color .15s;
}
.thread-reset:hover { color: var(--accent); border-color: var(--accent); }
.model-select {
  font: inherit; font-size: 11px; color: var(--muted);
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 6px; max-width: 150px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.model-select:hover { color: var(--text); border-color: var(--accent); }
.model-select:focus { outline: none; border-color: var(--accent); }
/* bolinha de "nova versão disponível" — só avisa, não troca (a caneta é do Tiago) */
.model-new {
  background: none; border: none; cursor: pointer; padding: 0 2px;
  color: #e5484d; font-size: 12px; line-height: 1;
  animation: model-new-pulse 1.8s ease-in-out infinite;
}
.model-new:hover { color: #c4292e; }
@keyframes model-new-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

#chat-log { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 26px 24px; display: flex; flex-direction: column; gap: 16px; }
.msg { overflow-wrap: anywhere; }

.msg { max-width: 92%; font-size: 14px; line-height: 1.65; overflow-wrap: break-word; }
.msg.fable { align-self: stretch; color: var(--text); }
.msg.fable :is(p, ul, ol) { margin: 8px 0; }
.msg.fable :first-child { margin-top: 0; }
.msg.fable :last-child { margin-bottom: 0; }
.msg.fable code { background: rgba(40, 46, 54, .07); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.msg.fable pre { background: rgba(40, 46, 54, .05); border: 1px solid var(--border); padding: 12px 14px; border-radius: 12px; overflow-x: auto; position: relative; }
.msg.fable pre code { background: none; padding: 0; }
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  font: 500 11px/1 system-ui, sans-serif;
  background: rgba(252, 253, 255, .92); border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px; padding: 4px 9px; cursor: pointer;
  opacity: 0; transition: opacity .15s, color .15s, border-color .15s;
}
.msg.fable pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }
.copy-btn.ok { color: var(--ok); border-color: var(--ok); opacity: 1; }
@media (hover: none) { .copy-btn { opacity: 1; } }
.msg.fable a { color: var(--accent); }
.msg.user { align-self: flex-end; max-width: 84%; padding: 11px 16px; background: var(--accent-soft); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 18px; border-bottom-right-radius: 6px; }
.msg.error { align-self: stretch; background: rgba(177, 90, 82, .08); border: 1px solid rgba(177, 90, 82, .3); color: #8a3d36; font-size: 13px; padding: 10px 14px; border-radius: 12px; }
.msg.tool { align-self: flex-start; color: var(--muted); font-size: 11.5px; padding: 0 2px; font-family: "Roboto Mono", ui-monospace, monospace; }
.msg.user img.att { display: block; max-width: 220px; border-radius: 12px; margin-top: 8px; }

/* cartão de pergunta — botões clicáveis no lugar do popup nativo */
.pergunta-card { margin: 10px 0; padding: 14px; background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); }
.pergunta-card .pergunta-q { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.pergunta-opcoes { display: flex; flex-direction: column; gap: 7px; }
.pergunta-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; background: rgba(252, 253, 255, .6); border: 1px solid var(--border); border-radius: 11px; padding: 9px 13px; cursor: pointer; font: inherit; transition: border-color .15s, background .15s, transform .05s; }
.pergunta-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.pergunta-opt:active { transform: translateY(1px); }
.pergunta-opt .opt-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.pergunta-opt .opt-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.pergunta-opt.escolhida { border-color: var(--accent); background: var(--accent-soft); }
.pergunta-card.respondido .pergunta-opt:not(.escolhida) { opacity: .5; }
.pergunta-opt:disabled { cursor: default; }

#chat-activity { padding: 8px 26px 0; display: flex; flex-direction: column; gap: 1px; }
#chat-activity[hidden] { display: none; }
#chat-activity .act-main { color: var(--accent); font-size: 12.5px; font-variant-numeric: tabular-nums; }
#chat-activity .act-note { color: var(--muted); font-size: 11px; }
#chat-activity .act-note-warn { color: var(--accent); font-weight: 500; }
@keyframes stop-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
#chat-stop.stop-warn { animation: stop-pulse 1.4s ease-in-out infinite; }

#chat-form {
  display: flex; flex-direction: column; gap: 8px; padding: 16px 22px 22px;
  background: linear-gradient(0deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0));
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 26px -18px rgba(40, 46, 54, .5);
  position: relative; z-index: 2;
}
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: var(--radius-lg); padding: 6px 6px 6px 12px; box-shadow: var(--shadow-soft); transition: border-color .2s, box-shadow .2s; }
.chat-input-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#chat-input { flex: 1; resize: none; background: none; border: none; color: var(--text); padding: 9px 6px; font: inherit; line-height: 1.5; max-height: 160px; min-height: 22px; }
#chat-input:focus { outline: none; }
#chat-input::placeholder { color: var(--muted); }
#chat-attach, #chat-send { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: none; transition: background .2s, color .2s, filter .2s; }
#chat-attach { background: none; color: var(--muted); }
#chat-attach:hover { background: rgba(40, 46, 54, .07); color: var(--text); }
#chat-send { background: var(--btn-dark); color: var(--on-dark); }
#chat-send:hover { filter: brightness(1.15); }
#chat-send:disabled { opacity: .4; cursor: default; filter: none; }
#chat-stop { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: none; background: var(--btn-dark); color: var(--on-dark); cursor: pointer; transition: filter .2s, opacity .2s; }
#chat-stop:hover { filter: brightness(1.15); }
#chat-stop:disabled { opacity: .5; cursor: default; }
#app-sos { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 2px 4px; border-radius: 4px; line-height: 1; transition: color .15s, background .15s; }
#app-sos:hover { color: #c0392b; background: rgba(192,57,43,.08); }
#app-sos.sos-active { color: #c0392b; }
#sos-banner { display: flex; align-items: center; gap: 10px; padding: 7px 18px; background: rgba(192,57,43,.09); border-bottom: 1px solid rgba(192,57,43,.22); font-size: 12.5px; color: #c0392b; }
#sos-banner[hidden] { display: none; }
#sos-banner button { margin-left: auto; font-size: 11.5px; padding: 2px 10px; border: 1px solid rgba(192,57,43,.4); border-radius: 4px; background: none; color: #c0392b; cursor: pointer; }
#sos-banner button:hover { background: rgba(192,57,43,.12); }

#chat-attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 4px; }
#chat-attachments:empty { display: none; }
#chat-attachments .thumb { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
#chat-attachments .thumb img { width: 100%; height: 100%; object-fit: cover; }
#chat-attachments .thumb button { position: absolute; top: 0; right: 0; background: #0008; border: none; color: #fff; font-size: 11px; line-height: 1; padding: 2px 5px; border-radius: 0 0 0 8px; }

/* ---------- workspace (painel de vidro) ---------- */
#workspace {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  transition: opacity .26s ease;
}
body.collapsed #workspace { opacity: 0; pointer-events: none; }
#ws-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 82px; padding: 0 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, .08));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 26px -18px rgba(40, 46, 54, .55);
  position: relative; z-index: 2;
}
#ws-title { font-size: 27px; font-weight: 300; letter-spacing: -.02em; }
#ws-close { background: none; border: none; color: var(--muted); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; transition: background .2s, color .2s; }
#ws-close:hover { background: rgba(40, 46, 54, .07); color: var(--text); }
#ws-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 30px 30px; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; padding-bottom: 18px; gap: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.view-header small { font-size: 12.5px; }
.task-tools { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
.task-tools .quick-add input[name="area"], #add-topic input { flex: 0 0 auto; min-width: 130px; }

/* ---------- abas: rail / bottom bar (sobre o gradiente, sem fundo próprio) ---------- */
#rail {
  flex: 0 0 90px;
  display: flex; flex-direction: column; align-items: stretch;
  gap: 8px; padding: 72px 0 18px; background: transparent;
}
.rail-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: none; border: none; color: var(--muted);
  width: 100%; padding: 11px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: background .22s ease, color .2s ease, box-shadow .22s ease, backdrop-filter .22s;
}
.rail-btn span { font-size: 11px; font-weight: 500; letter-spacing: .2px; }
.rail-chat { display: none; } /* "Chat" é aba só no mobile; no desktop o chat já está sempre visível */
.rail-btn:hover:not(.active) { color: var(--text); }
.rail-btn.active {
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--accent);
  box-shadow: -8px 0 26px -14px rgba(40, 46, 54, .35);
}
.rail-spacer { flex: 1; }
.rail-status { align-self: center; color: var(--danger); font-size: 9px; transition: color .3s; }
.rail-status.on { color: var(--ok); }
.rail-more-btn { display: none; } /* só aparece no mobile via @media portrait */

/* ---------- kanban ---------- */
#board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 18px; align-items: start; overflow-x: auto; padding-bottom: 10px; }
.col { background: rgba(255, 255, 255, .22); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 150px; }
.col.dragover { border-color: var(--accent); background: var(--accent-soft); }
.col h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); padding: 2px 4px 14px; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 600; }
.col h3 .count { background: var(--accent-soft); color: var(--accent); padding: 1px 8px; border-radius: 99px; font-size: 10px; font-weight: 600; }
.col-remove { background: none; border: none; color: var(--muted); font-size: 12px; padding: 0 4px; }
.col-remove:hover { color: var(--danger); }
.col-add { margin-top: 8px; }
.col-add input { width: 100%; background: transparent; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); padding: 8px 12px; font: inherit; }
.col-add input:focus { outline: none; border-color: var(--accent); border-style: solid; color: var(--text); }

.card { background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; cursor: grab; box-shadow: var(--shadow-soft); transition: box-shadow .15s, transform .15s, background .15s; }
.card:hover { background: var(--card-glass-hover); box-shadow: var(--shadow); transform: translateY(-1px); }
.card:active { cursor: grabbing; }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-top .title { flex: 1; min-width: 0; }
.card .title {
  font-weight: 500; font-size: 14px; line-height: 1.35;
  padding: 6px 11px; border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .4);
  background:
    radial-gradient(at 0% 0%, rgba(146, 178, 214, .30), transparent 70%),
    radial-gradient(at 100% 100%, rgba(168, 204, 196, .26), transparent 70%),
    linear-gradient(120deg, rgba(200, 176, 214, .18), rgba(255, 255, 255, .12));
  box-shadow: var(--shadow-soft);
}
.card .desc { color: var(--muted); font-size: 12.5px; margin-top: 5px; line-height: 1.5; }
.card .meta { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 11px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border); background: rgba(255, 255, 255, .32); color: var(--muted); }
.card .arch { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .15s, color .15s; }
.card:hover .arch { opacity: 1; }
.card .arch:hover { color: var(--ok); }

/* indicador de prioridade */
.prio { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; flex: 0 0 auto; margin-top: 2px; cursor: pointer; }
.prio i { width: 3px; border-radius: 2px; background: var(--border-strong); transition: background .2s; }
.prio i:nth-child(1) { height: 6px; }
.prio i:nth-child(2) { height: 9px; }
.prio i:nth-child(3) { height: 12px; }
.prio[data-nivel="1"] i:nth-child(-n+1),
.prio[data-nivel="2"] i:nth-child(-n+2),
.prio[data-nivel="3"] i:nth-child(-n+3) { background: var(--accent); }

.prio-pop { position: fixed; z-index: 60; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.prio-pop-bars { display: flex; align-items: flex-end; gap: 6px; height: 26px; }
.prio-pop .pb { background: none; border: none; padding: 2px; display: flex; align-items: flex-end; height: 26px; }
.prio-pop .pb i { display: block; width: 8px; border-radius: 2px; background: var(--border-strong); transition: background .15s; }
.prio-pop .pb:nth-child(1) i { height: 12px; }
.prio-pop .pb:nth-child(2) i { height: 19px; }
.prio-pop .pb:nth-child(3) i { height: 26px; }
.prio-pop .pb:hover i { background: var(--muted); }
.prio-pop .pb.on i { background: var(--accent); }
.prio-pop-cap { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

/* ---------- tarefas: lista por tópico + sub-tarefas ---------- */
.tarefas-head { align-items: center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--card-glass); color: var(--muted); font-size: 13px; font-weight: 500; transition: background .15s, color .15s, border-color .15s; }
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--btn-dark); border-color: var(--btn-dark); color: var(--on-dark); }
.t-contador { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); font-size: 16px; white-space: nowrap; }
.t-contador span { color: var(--muted); font-weight: 400; font-size: 13px; }
.t-add { margin-bottom: 16px; }
.t-lista { display: flex; flex-direction: column; gap: 8px; }
.t-sep { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 16px 0 4px; }

.t-item { background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 12px; box-shadow: var(--shadow-soft); }
.t-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.t-check { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--border-strong); background: none; color: var(--on-dark); display: grid; place-items: center; font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s; }
.t-check:hover { border-color: var(--accent); }
.t-item.feita .t-check { background: var(--accent); border-color: var(--accent); }
.t-titulo { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; }
.t-item.feita .t-titulo { text-decoration: line-through; color: var(--muted); }
.t-sub-prog { flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); background: rgba(255, 255, 255, .4); border: 1px solid var(--border); padding: 1px 8px; border-radius: 99px; }
.t-row .prio { flex: 0 0 auto; }
.t-exp, .t-arch { flex: 0 0 auto; background: none; border: none; color: var(--muted); font-size: 13px; width: 28px; height: 28px; border-radius: 8px; }
.t-exp:hover, .t-arch:hover { background: rgba(40, 46, 54, .07); color: var(--text); }
.t-arch:hover { color: var(--danger); }
.t-row { padding-bottom: 8px; }

/* barra de progresso das sub-tarefas (segunda linha) */
.t-bar-line { display: flex; align-items: center; gap: 10px; padding: 0 14px 12px; }
.t-bar { flex: 1; height: 6px; border-radius: 99px; background: rgba(40, 46, 54, .1); overflow: hidden; }
.t-bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #46b069, #58c47b); transition: width .35s cubic-bezier(.2, 0, 0, 1); }
.t-bar-pct { flex: 0 0 auto; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); min-width: 30px; text-align: right; }
.t-item.feita .t-bar-fill { background: linear-gradient(90deg, #46b069, #58c47b); }

.t-detalhe { display: none; padding: 0 14px 14px 48px; }
.t-item.aberta .t-detalhe { display: block; }
.t-desc { color: var(--muted); font-size: 13px; line-height: 1.55; margin-bottom: 10px; white-space: pre-wrap; }
.t-subs { display: flex; flex-direction: column; gap: 5px; }
.t-sub { display: flex; align-items: center; gap: 10px; }
.t-sub-check { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: none; color: var(--on-dark); display: grid; place-items: center; font-size: 11px; cursor: pointer; transition: background .15s, border-color .15s; }
.t-sub-check:hover { border-color: var(--accent); }
.t-sub.feita .t-sub-check { background: var(--accent); border-color: var(--accent); }
.t-sub span { flex: 1; min-width: 0; font-size: 13px; }
.t-sub.feita span { text-decoration: line-through; color: var(--muted); }
.t-sub-x { flex: 0 0 auto; background: none; border: none; color: var(--muted); font-size: 11px; opacity: 0; transition: opacity .15s, color .15s; }
.t-sub:hover .t-sub-x { opacity: 1; }
.t-sub-x:hover { color: var(--danger); }
.t-sub-add { margin-top: 10px; }
.t-sub-add input { width: 100%; background: transparent; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); padding: 7px 11px; font: inherit; }
.t-sub-add input:focus { outline: none; border-color: var(--accent); border-style: solid; color: var(--text); }

/* ---------- listas (acervo / protocolos / mente / e-mail) ---------- */
.item { position: relative; background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow-soft); transition: box-shadow .18s, transform .18s; }
.item:hover { box-shadow: var(--shadow); }
.item--pendente { border-left: 2px solid var(--accent); }
.item--confirmado { opacity: .82; }
.item .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.item .head .title { font-weight: 600; font-size: 15px; }
.item .head a { color: var(--accent); font-size: 13px; text-decoration: none; }
.item .body { color: var(--muted); font-size: 13.5px; line-height: 1.65; margin-top: 10px; }
.item .body :is(p, ul, ol) { margin: 6px 0; }
.item .body a { color: var(--accent); }
.item .body code { background: rgba(40, 46, 54, .07); padding: 1px 5px; border-radius: 5px; }
.item .body :is(h1, h2, h3) {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text); margin: 16px 0 4px; padding-top: 10px; border-top: 1px solid var(--hair);
}
.item .body :is(h1, h2, h3):first-child { margin-top: 8px; padding-top: 0; border-top: none; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); border-top-color: var(--hair); background: var(--card-glass); color: var(--muted); }
.badge.pendente { border-color: var(--accent); color: var(--accent); }
.badge.confirmado { border-color: var(--ok); color: var(--ok); }
.item .actions { margin-top: 14px; display: flex; gap: 8px; }
.mente-note { font-style: normal; }

/* aba de agentes */
.tok { font-size: 10.5px; color: var(--muted); background: rgba(40,46,54,.06); padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.btn.tiny { font-size: 11px; padding: 2px 9px; }
.ag-bib { border: 1px solid var(--hair); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; background: var(--card-glass); }
.ag-bib-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.ag-bib-head small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.ag-bib-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ag-bloco { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 9px; }
.ag-bloco:hover { background: rgba(40,46,54,.04); }
.ag-bloco-nome { font-size: 13px; flex: 1; font-family: ui-monospace, monospace; }
.ag-bib-add { display: flex; gap: 6px; }
.ag-bib-add input { flex: 1; }
.ag-card .head { align-items: center; }
.ag-card .ag-desc { margin-left: auto; color: var(--muted); }
.ag-exp { background: none; border: none; color: var(--accent); font-size: 12px; cursor: pointer; }
.ag-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.ag-detalhe { margin-top: 12px; border-top: 1px solid var(--hair); padding-top: 12px; display: flex; flex-direction: column; gap: 16px; }
.ag-sec label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.ag-sec label small { font-weight: 400; color: var(--muted); }
.ag-sec textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; background: var(--glass); color: var(--text); resize: vertical; }
.ag-nucleo { font-family: ui-monospace, monospace; font-size: 12.5px; }
.ag-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.ag-blocos { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 99px; cursor: pointer; font-size: 12px; font-weight: 400; }
.ag-toggle.on { border-color: var(--accent); background: rgba(95,127,150,.1); color: var(--text); }
.ag-toggle input { margin: 0; }
.ag-saida { margin-top: 8px; white-space: pre-wrap; font-size: 13px; line-height: 1.55; background: var(--glass); border: 1px solid var(--hair); border-radius: 10px; padding: 10px 12px; }
.ag-modal { position: fixed; inset: 0; background: rgba(20,24,28,.4); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.ag-modal-box { background: var(--bg, #fff); border-radius: 16px; padding: 16px 18px; width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.ag-modal-head { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.ag-modal-x { margin-left: auto; background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.ag-modal-ta { flex: 1; width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, monospace; font-size: 12.5px; line-height: 1.5; resize: none; background: var(--glass); color: var(--text); }

/* notificações */
.rail-btn { position: relative; }
.rail-badge {
  position: absolute; top: 4px; right: 8px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 600;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  border-radius: 99px; padding: 0 4px; box-sizing: border-box;
}
.notif.nao-lida { border-left: 3px solid var(--accent); background: rgba(95, 127, 150, .06); cursor: pointer; }
.notif.nao-lida .title { font-weight: 600; }
.notif-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* aba de e-mail */
.email-resumo .body { color: var(--text); }
.email-resumo .body :is(h1, h2, h3) { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
.email-resumo .body :is(h1, h2, h3)::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); flex: 0 0 auto; }
.email-resumo .body :first-child { margin-top: 0; }
.email-resumo .body strong { color: var(--text); font-weight: 600; }
.email-resumo .body ul { padding-left: 18px; margin: 6px 0; }
.email-resumo .body li { margin: 4px 0; }
.email-resumo .body hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.email-futuro { margin-top: 16px; padding: 14px 16px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }

/* aba de agenda */
.agenda-day { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.agenda-day:first-of-type { margin-top: 0; }
.agenda-ev .head { align-items: center; gap: 12px; }
.agenda-ev .agenda-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); min-width: 46px; flex: 0 0 auto; }
.agenda-ev .title { flex: 1; min-width: 0; font-weight: 500; font-size: 14px; }
.agenda-ev .agenda-local { color: var(--muted); font-size: 12.5px; flex: 0 0 auto; }
.agenda-ev .agenda-link { color: var(--accent); font-size: 13px; text-decoration: none; white-space: nowrap; flex: 0 0 auto; }
.agenda-ev .arch { background: none; border: none; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .15s, color .15s; flex: 0 0 auto; }
.agenda-ev:hover .arch { opacity: 1; }
.agenda-ev .arch:hover { color: var(--danger); }
.item .head .arch { background: none; border: none; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity .15s, color .15s; padding: 0 2px; }
.item:hover .head .arch { opacity: 1; }
.item .head .arch:hover { color: var(--danger); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chk input { accent-color: var(--accent); }

/* grade do mês */
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-month { font-size: 18px; font-weight: 500; text-transform: capitalize; min-width: 150px; text-align: center; }
.cal-arrow { background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 50%; width: 32px; height: 32px; font-size: 16px; line-height: 1; color: var(--text); display: grid; place-items: center; }
.cal-arrow:hover { border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.cal-wd { text-align: center; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 2px 0 6px; }
.cal-cell { min-height: 62px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 0 0; background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 12px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.cal-cell:hover { box-shadow: var(--shadow-soft); }
.cal-cell.out { opacity: .38; }
.cal-cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-d { font-size: 13px; font-weight: 500; width: 26px; height: 26px; display: grid; place-items: center; }
.cal-cell.hoje .cal-d { background: var(--accent); color: var(--on-dark); border-radius: 50%; }
.cal-dots { display: flex; gap: 3px; }
.cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-day-panel { margin-top: 24px; }
.cal-day-title { font-size: 14px; font-weight: 600; text-transform: capitalize; color: var(--text); margin-bottom: 12px; }
.cal-day-add { margin-top: 14px; }

/* ---------- botões / forms ---------- */
.btn { padding: 9px 18px; border-radius: 99px; border: 1px solid var(--border); background: var(--card-glass); color: var(--text); font-size: 13px; font-weight: 500; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow-soft); }
.btn.primary { background: var(--btn-dark); border-color: var(--btn-dark); color: var(--on-dark); }
.btn.primary:hover { filter: brightness(1.15); background: var(--btn-dark); }
.btn.ghost-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--card-glass); }

.quick-add { display: flex; gap: 8px; }
.quick-add input, .quick-add select { background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair); border-radius: 99px; color: var(--text); padding: 9px 15px; font: inherit; transition: border-color .15s, box-shadow .15s; }
.quick-add input { flex: 1; min-width: 120px; }
.quick-add input:focus, .quick-add select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-add input::placeholder { color: var(--muted); }

.empty { color: var(--muted); padding: 36px 0; text-align: center; font-style: italic; }

/* ---------- avatar + página pessoal de Fable ---------- */
#me-btn {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 14px); right: 24px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--accent);
  border: 1px solid var(--border); border-top-color: var(--hair); box-shadow: var(--shadow-soft);
  transition: box-shadow .25s, border-color .25s, transform .2s;
}
#me-btn:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }

#me-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(40, 46, 54, .4); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 28px;
  animation: me-fade .22s ease;
}
#me-overlay[hidden] { display: none; }
@keyframes me-fade { from { opacity: 0; } to { opacity: 1; } }
#me-frame {
  width: min(960px, 100%); height: min(86vh, 820px);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: #0a0e0f; box-shadow: 0 30px 80px -24px rgba(40, 46, 54, .55);
  animation: me-rise .26s cubic-bezier(.2, 0, 0, 1);
}
@keyframes me-rise { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }
#me-close {
  position: fixed; top: 24px; right: 28px; z-index: 51;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--text); border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
}
#me-close:hover { border-color: var(--border-strong); }

/* ---------- rail sheet (só usado no mobile) ---------- */
#rail-sheet {
  display: none; /* começa oculto; JS remove o hidden + CSS mobile cuida do resto */
}

/* ---------- vertical (segunda tela em retrato) ---------- */
@media (orientation: portrait) {
  body { flex-direction: column; }
  /* mobile = uma tela por vez: a visão ativa ocupa tudo; o chat ocupa tudo quando "fechado" */
  #layout { grid-template-columns: 1fr; grid-template-rows: 0% 100%; }
  body.collapsed #layout { grid-template-columns: 1fr; grid-template-rows: 100% 0%; }
  #chat { border-right: none; border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }

  #rail {
    flex: 0 0 auto; flex-direction: row; align-items: stretch;
    justify-content: space-around; gap: 4px;
    padding: 8px 6px calc(env(safe-area-inset-bottom) + 12px);
    background: rgba(250, 251, 253, .55);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
  }
  .rail-chat { display: flex; }
  .rail-btn { flex: 1; min-width: 0; padding: 0; gap: 4px; justify-content: center; border-radius: 0; }
  .rail-btn span { font-size: 10px; }
  /* indicador = quadrado arredondado em volta do ícone (fechado, sem lado aberto) */
  .rail-btn svg { box-sizing: content-box; padding: 8px 10px; border-radius: 13px; transition: background .2s, box-shadow .2s; }
  .rail-btn.active { margin-top: 0; background: none; backdrop-filter: none; box-shadow: none; }
  .rail-btn.active svg { background: #fff; box-shadow: 0 2px 8px -3px rgba(40, 46, 54, .25); }
  .rail-spacer { display: none; }
  .rail-status { position: absolute; top: 12px; right: 16px; }

  /* botões secundários ficam no sheet, não no rail */
  .rail-secondary { display: none !important; }

  /* botão "Mais" aparece no mobile */
  .rail-more-btn { display: flex !important; }

  /* sheet expansível */
  #rail-sheet {
    display: block;
    position: fixed; left: 0; right: 0; z-index: 20;
    bottom: calc(56px + env(safe-area-inset-bottom));  /* logo acima do rail */
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.22, 1, .36, 1), opacity .2s;
  }
  #rail-sheet:not([hidden]) {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  #rail-sheet-inner {
    margin: 0 12px 8px;
    background: rgba(250, 251, 253, .92);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-top-color: var(--hair);
    border-radius: var(--radius-lg);
    box-shadow: 0 -4px 30px -6px rgba(40, 46, 54, .18);
    overflow: hidden;
  }
  .rail-sheet-btn {
    display: flex; align-items: center; gap: 14px; width: 100%;
    padding: 15px 20px; background: none; border: none;
    color: var(--text); font: inherit; font-size: 14.5px; font-weight: 500;
    text-align: left; cursor: pointer;
    transition: background .15s;
  }
  .rail-sheet-btn:hover, .rail-sheet-btn:active { background: rgba(0,0,0,.04); }
  .rail-sheet-btn svg { color: var(--muted); flex: none; }
  .rail-sheet-divider {
    height: 1px; background: var(--border); margin: 0 16px;
  }
  .rail-sheet-sos {
    color: #c0392b !important;
  }
  .rail-sheet-sos svg { color: #c0392b !important; stroke: #c0392b; }
  .rail-sheet-sos:hover, .rail-sheet-sos:active { background: rgba(192,57,43,.06) !important; }

  /* sem scroll horizontal: cabeçalhos/corpo com menos padding, formulários quebram linha */
  #ws-head { padding: 20px 18px 8px; }
  #ws-body { padding: 12px 16px 24px; }
  .quick-add { flex-wrap: wrap; }
  .quick-add input, .quick-add select,
  .task-tools .quick-add input[name="area"], #add-topic input { min-width: 0; flex: 1 1 130px; }
  #board { grid-auto-columns: minmax(78vw, 1fr); }
}

/* dispositivos de toque: controles que apareciam só no hover ficam sempre visíveis */
@media (hover: none) {
  .card .arch, .agenda-ev .arch, .item .head .arch, .t-sub-x { opacity: 1; }
}

/* ---------- tela de login (só em acesso remoto) ---------- */
#login-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(at 8% 12%, rgba(146, 178, 214, .5), transparent 42%),
    radial-gradient(at 92% 80%, rgba(160, 204, 196, .45), transparent 46%),
    #e7eaee;
}
#login-form {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 36px 40px; width: min(320px, 86vw);
  background: var(--card-glass); border: 1px solid var(--border); border-top-color: var(--hair);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
#login-form .brand-mark { color: var(--text); }
#login-form h2 { font-size: 20px; font-weight: 300; letter-spacing: -.01em; }
#login-form input {
  width: 100%; text-align: center; font: inherit; color: var(--text);
  background: rgba(255, 255, 255, .55); border: 1px solid var(--border); border-radius: 99px; padding: 11px 16px;
}
#login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#login-form .btn { width: 100%; }
#login-erro { color: var(--danger); min-height: 1em; font-size: 12.5px; }

/* -------------------------------------------------------------- rebarbas
   Cada agente trabalhando vira uma abinha pixel grudada na borda direita —
   sprite (mini_claude, do claude-quest, MIT) + nome + loading. O âmbar (meu
   detalhe) marca o acento. Sprite: folha 192x64, frame 16x16, escala 2.5 →
   40px; a linha 1 (Idle, 8 frames) é o "trabalhando". */
:root { --rb-amber: #c98a3a; --rb-amber-soft: rgba(201, 138, 58, .16); }
#rebarbas {
  position: absolute; top: 90px; left: 14px; z-index: 3;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
.rebarba {
  pointer-events: auto; display: flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 8px;
  background: var(--card-glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-top-color: var(--hair);
  border-left: 3px solid var(--rb-amber);
  border-radius: 14px;
  box-shadow: 0 6px 18px -6px rgba(40, 46, 54, .28);
  transform: translateX(-16px); opacity: 0;
  transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .26s;
}
.rebarba.show { transform: translateX(0); opacity: 1; }
.rb-sprite {
  width: 40px; height: 40px; flex: none;
  background: url("assets/mini_claude.png") no-repeat;
  background-size: 480px 160px; background-position: 0 -40px;
  image-rendering: pixelated;
  animation: rb-work .9s steps(8) infinite;
}
@keyframes rb-work { from { background-position: 0 -40px; } to { background-position: -320px -40px; } }
.rb-meta { display: flex; flex-direction: column; gap: 3px; }
.rb-nome { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1; }
.rb-load { display: inline-flex; gap: 3px; }
.rb-load i { width: 4px; height: 4px; border-radius: 50%; background: var(--rb-amber); opacity: .35; animation: rb-dot 1.1s infinite; }
.rb-load i:nth-child(2) { animation-delay: .18s; }
.rb-load i:nth-child(3) { animation-delay: .36s; }
@keyframes rb-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) {
  .rb-sprite, .rb-load i { animation: none; }
  .rebarba { transition: opacity .2s; transform: none; }
}
