/* ---------- dock ---------- */

#caption {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 14px;
  max-height: 30vh;
  overflow: auto;
  transition: opacity 0.36s var(--ease), max-height 0.36s var(--ease);
}
#caption.leaving { opacity: 0; max-height: 0; pointer-events: none; }
#caption .activity:empty, #caption .text:empty { display: none; }
#caption .text { color: var(--fg); }
#caption .text .md p { margin: 0 0 0.4em; }
#caption.error .text { color: var(--danger); }
#caption .spinner { display: none; }
body.busy #caption .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
  align-self: center;
  border-radius: 50%;
  background: conic-gradient(#22d3ee, #8b5cf6, #ec4899, #f59e0b, #22d3ee);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 1.5px));
  filter: drop-shadow(0 0 3px #8b5cf6);
  animation: spin 0.9s linear infinite;
}
body.busy #caption .spinner { cursor: pointer; }
/* The chatter box: the model's live stream, opened from the spinner (ui/js/stage/chatter.js). */
#chatter {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10; /* over the message box's wrap and its menus */
  height: calc(5 * 1.45em + 16px);
  /* No scrolling: the newest rows sit at the bottom and older ones fall off the top. */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  overflow-clip-margin: content-box;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#chatter[hidden] { display: none; }
#chatter:empty::before { content: attr(data-empty); color: var(--muted); font-style: italic; }
#chatter .blk { flex-shrink: 0; border-left: 2px solid var(--muted); padding-left: 8px; margin-bottom: 4px; }
#chatter .label { margin-right: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
#chatter .blk.thinking { border-color: #8b5cf6; }
#chatter .blk.thinking .label { color: #8b5cf6; }
#chatter .blk.thinking span:last-child { color: var(--muted); font-style: italic; }
#chatter .blk.text { border-color: #22c55e; }
#chatter .blk.text .label { color: #22c55e; }
#chatter .blk.tool { border-color: var(--accent); }
#chatter .blk.tool .label { color: var(--accent); }
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50% { transform: scale(1); opacity: 1; }
}

.composer-wrap { position: relative; z-index: 9; } /* above the waiting veil, so the / menu and suggestions stay visible */
#composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 9px 9px 9px 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}
#composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
/* Files dragged over the message box: they are stored with the person's files when dropped. */
#composer { position: relative; }
#composer.file-over { border: 1px dashed var(--accent); }
#composer.file-over::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: color-mix(in srgb, var(--surface) 88%, var(--accent));
  color: var(--fg);
  font-weight: 600;
  pointer-events: none;
}
/* Documents and text files attached to the next request (composer/attachments.js). */
#attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 8px;
}
#attachments[hidden] { display: none; }
.attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 4px 4px 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.attachment svg { width: 18px; height: 18px; flex: none; }
.attachment .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .remove {
  width: 20px;
  height: 20px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.attachment .makedb { width: 20px; height: 20px; flex: none; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.attachment .makedb svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.attachment .makedb:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.attachment .remove:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--fg); }
#input {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
  padding: 6px 0;
  max-height: 200px;
}
#input::placeholder { color: var(--muted); }
#send {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
#send:active { transform: scale(0.94); }
#send:disabled { opacity: 0.3; cursor: default; }
#send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#send .icon-stop { display: none; fill: currentColor; stroke: none; }
body.busy #send .icon-send { display: none; }
body.busy #send .icon-stop { display: block; }

#share {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
#share[hidden] { display: none; }
#share:hover, #share[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); }
#share.public { color: var(--accent); }
#share svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#sharemenu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: min(320px, 100%);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}
#sharemenu[hidden] { display: none; }
#sharemenu button {
  display: grid;
  grid-template-columns: 1fr 18px;
  column-gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
#sharemenu button:hover, #sharemenu button:focus-visible { background: var(--surface-2); outline: 0; }
#sharemenu .label { font-size: 14px; font-weight: 500; }
#sharemenu .desc { grid-column: 1; font-size: 12px; line-height: 1.4; color: var(--muted); margin-top: 2px; }
#sharemenu .page-unpublish { margin-left: 4px; white-space: nowrap; }
#sharemenu .page-unpublish:hover, #sharemenu .page-unpublish:focus-visible { color: var(--danger); }
#sharemenu .page-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; word-break: break-all; }
#sharemenu .check { grid-column: 2; grid-row: 1; width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
#sharemenu button.on .check { visibility: visible; }

#meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
#meta.rate-room { min-height: 24px; }
/* The open app's controls: a half-height box left of the message box, faint until hovered. */
#appbox {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  height: 50%;
  min-height: 30px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0.3;
  transition: opacity 0.15s;
  white-space: nowrap;
  user-select: none;
}
#appbox:hover, #appbox:focus-within { opacity: 1; }
#appbox:not(:has(> :not([hidden]))) { display: none; }
/* narrow windows: the message box gives up width so the box beside it stays on screen */
#dock:has(#appbox > :not([hidden])) { width: min(760px, max(55%, 100% - 400px)); }
#pause, #askchat, #appprompts {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
#pause:hover, #askchat:hover, #appprompts:hover, #appprompts.on { color: var(--accent); }
#pause svg, #askchat svg, #appprompts svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#pause svg { stroke-width: 2.6; }
#closeapp { display: grid; place-items: center; padding: 0; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
#closeapp svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
#closeapp:hover, #closeapp:focus-visible { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
#present, #unpresent {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
#present { width: 22px; height: 22px; }
#present:hover { color: var(--accent); }
#present svg, #unpresent svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- full-screen app: everything but the app and one small exit button is hidden ---------- */

#unpresent {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  width: 32px;
  height: 32px;
  padding: 8px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0.45;
  transition: opacity 0.15s;
}
#unpresent:hover, #unpresent:focus-visible { opacity: 1; color: var(--accent); }
/* On entering, the exit button is shown plainly for a moment, then settles back. */
body.presenting #unpresent:not(:hover):not(:focus-visible) { animation: unpresent-hint 4s var(--ease); }
@keyframes unpresent-hint { 0%, 75% { opacity: 1; color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { body.presenting #unpresent { animation: none !important; } }
.present-hint {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 30;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: none;
  transform: translateX(-50%);
  animation: present-hint 3.5s var(--ease) forwards;
}
@keyframes present-hint {
  0% { opacity: 0; transform: translate(-50%, -8px); }
  10%, 80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}
body.presenting #app { padding: 0; gap: 0; }
body.presenting #title, body.presenting #dock, body.presenting #rail { display: none !important; }
body.presenting #app.active #stage { position: fixed; inset: 0; width: auto; } /* no z-index: the waiting veil inside must stack above the tasks */
/* How long the last turn took, for a moment after it ends (agent.js `showTurnTime`). */
#turn-time {
  position: absolute;
  right: 18px;
  bottom: calc(100% + 6px);
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#turn-time.on { opacity: 1; }
