/* Convergence Brain workspace shell */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Conversation fills the space; agents + workspaces stay compact at the bottom. */
.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
  background: #0f141a;
}
.shell > * { min-width: 0; }

.shell button { min-height: 2.25rem; padding: .4rem .8rem; font-size: .86rem; }
.shell button:focus-visible, .shell textarea:focus-visible { outline: 2px solid #f3bb81; outline-offset: 2px; }

.shell-bar { display: flex; align-items: center; gap: .8rem; padding: .5rem clamp(.9rem, 3vw, 1.5rem); }
.shell-brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; font-size: .9rem; color: #aeb8c2; margin-right: auto; white-space: nowrap; }
.preview-flag { margin: 0; color: #f3cfa6; font-size: .8rem; }
.shell-alert { margin: 0; color: #ff9d92; font-size: .8rem; max-width: 46ch; }
.shell-alert:empty { display: none; }
.shell .shell-quiet { background: transparent; color: #aeb8c2; }
.shell .shell-quiet:hover:not(:disabled) { background: #1a222b; color: #eef1f4; }

/* ---------- conversation ---------- */
.convo {
  min-height: 0;
  width: min(100%, 52rem);
  margin-inline: auto;
  padding: .75rem clamp(.9rem, 3vw, 1.5rem);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.convo-head { display: flex; align-items: center; gap: .8rem; }
.convo-id { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-right: auto; }
.convo-head h1 { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; font-weight: 650; }
.convo-head h1:focus { outline: none; }
.convo-meta { color: #8e9aa6; font-size: .86rem; }

.status-pill, .agent-state { font-size: .74rem; font-weight: 500; color: #8e9aa6; }
[data-tone="on"] .agent-state, .status-pill[data-tone="on"] { color: #8fdca4; }
[data-tone="busy"] .agent-state, .status-pill[data-tone="busy"],
[data-tone="warn"] .agent-state, .status-pill[data-tone="warn"] { color: #f3cfa6; }

.scratch { background: #151c23; border-radius: .5rem; padding: .6rem .75rem; }
.scratch label { display: block; font-size: .82rem; font-weight: 600; margin: 0 0 .35rem; }
.scratch-storage { display: block; font-weight: 400; color: #8e9aa6; font-size: .74rem; margin-top: .1rem; }
.scratch textarea, .composer textarea {
  width: 100%;
  resize: none;
  border: 0;
  background: transparent;
  color: #eef1f4;
  font: inherit;
  font-size: .95rem;
  padding: .35rem .4rem;
}
.scratch textarea { resize: vertical; min-height: 4.5rem; max-height: 30vh; font-size: .88rem; }

.thread { flex: 1; min-height: 0; overflow-y: auto; padding: .5rem 0; }
.thread.is-empty { display: grid; place-items: center; }
.thread-empty { margin: 0; text-align: center; color: #6f7c89; font-size: .92rem; }
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.messages:empty { display: none; }
.msg { max-width: 46rem; }
.msg-user { align-self: flex-end; max-width: min(36rem, 88%); background: #1a222b; border-radius: .6rem; padding: .55rem .75rem; }
.msg-who { margin: 0 0 .2rem; font-size: .74rem; font-weight: 600; color: #8e9aa6; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: .94rem; }
.msg-meta { margin: .35rem 0 0; font-size: .76rem; color: #8e9aa6; }
.msg-meta.tone-error { color: #ff9d92; }
.msg-meta.tone-warn, .msg-meta.tone-busy { color: #f3cfa6; }
.shell .msg-action { margin-top: .35rem; min-height: 1.9rem; padding: .2rem .6rem; font-size: .78rem; }

.composer { background: #151c23; border-radius: .6rem; padding: .45rem .5rem; }
.composer textarea::placeholder { color: #6f7c89; }
.composer textarea:focus { outline: none; }
.composer:focus-within { box-shadow: 0 0 0 1px #3a4652; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
#composer-note { color: #6f7c89; font-size: .76rem; padding-left: .4rem; }
.shell .send { background: #f3bb81; color: #1d1209; min-width: 4.5rem; }
.shell .send:hover:not(:disabled) { background: #ffd3a7; }
.shell .send:disabled { background: #1a222b; color: #6f7c89; opacity: 1; }

.route-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem .5rem;
  margin: .2rem .3rem .45rem;
  padding: .45rem .6rem;
  border-radius: .45rem;
  background: #1f1c17;
}
.route-notice p { margin: 0; flex: 1 1 16rem; font-size: .82rem; color: #f3cfa6; }
.shell .route-notice button { min-height: 2rem; padding: .25rem .65rem; font-size: .8rem; }

/* ---------- agents ---------- */
.agents { display: flex; align-items: center; gap: .75rem; padding: .5rem clamp(.9rem, 3vw, 1.5rem); }
.agent-tabs { display: flex; flex-direction: column; gap: .2rem; flex: none; }
.shell .agent-tab { min-height: 1.75rem; padding: .15rem .6rem; font-size: .78rem; background: transparent; color: #6f7c89; text-align: left; }
.shell .agent-tab:hover:not(:disabled) { background: transparent; color: #eef1f4; }
.shell .agent-tab[aria-selected="true"] { color: #eef1f4; background: #1a222b; }
.agent-page { flex: 1; min-width: 0; }
.agent-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }

.shell .agent { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; min-height: 2.9rem; padding: .35rem .7rem; text-align: left; }
.agent-name { font-size: .9rem; font-weight: 600; line-height: 1.2; }
.shell .agent[aria-checked="true"], .shell .agent[aria-checked="true"]:hover { background: #f3bb81; color: #1d1209; }
.shell .agent[aria-checked="true"] .agent-state { color: #4a2f12; }

/* ---------- workspaces ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.shell .chip { background: transparent; color: #8e9aa6; font-weight: 500; }
.shell .chip:hover:not([aria-checked="true"]) { background: #1a222b; color: #eef1f4; }
.shell .chip[aria-checked="true"] { background: #1a222b; color: #f3bb81; font-weight: 600; }

.workspaces {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .35rem clamp(.9rem, 3vw, 1.5rem) max(.5rem, env(safe-area-inset-bottom));
  border-top: 1px solid #1a222b;
}
.workspaces-label { color: #6f7c89; font-size: .78rem; white-space: nowrap; }

@media (max-width: 640px) {
  .shell-bar { flex-wrap: wrap; row-gap: .25rem; }
  .preview-flag { order: 3; width: 100%; }
  .convo { gap: .5rem; padding-top: .4rem; }
  .convo-head h1 { font-size: 1.15rem; }
  .agents { flex-direction: column; align-items: stretch; gap: .3rem; padding-block: .35rem; }
  .agent-tabs { flex-direction: row; }
  .agent-grid { gap: .25rem; }
  .shell .agent { padding: .3rem .45rem; min-height: 2.75rem; }
  .agent-name { font-size: .82rem; }
  .agent-state { font-size: .68rem; }
  .workspaces-label { display: none; }
  .workspaces .chip-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .shell .chip { flex: none; min-height: 2.5rem; }
}
