/* Chatbox — task-document chat. The knowledge layer (task-sharded profile
 * documents, spec Feature 8) is not built yet; until it is, the page renders
 * the honest empty state and this file mostly styles the future thread. */
.task-doc-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.task-doc-tabs::-webkit-scrollbar {
  display: none;
}

.task-doc-tab {
  flex: 0 0 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1px solid rgba(23, 23, 23, .22);
  border-bottom-width: 3px;
  border-radius: 999px;
  font-family: var(--font-label);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.task-doc-tab.is-active,
.task-doc-tab[aria-current="page"] {
  color: var(--paper);
  background: var(--teal);
  border-color: var(--teal);
}

.chat-provenance {
  display: grid;
  gap: 2px;
  margin: 12px 12px 0;
  padding: 10px;
  background: rgba(62, 92, 84, .12);
  border: 1px solid rgba(62, 92, 84, .34);
  border-radius: var(--radius-sm);
}

.chat-provenance span {
  color: var(--teal);
  font-family: var(--font-label);
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.chat-provenance strong {
  font-size: .92rem;
}

.chat-thread {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 11px;
  border-radius: 16px;
  border: 1px solid rgba(23, 23, 23, .16);
}

.chat-message p {
  margin: 0;
}

.chat-message p + p {
  margin-top: 8px;
}

.from-user {
  justify-self: end;
  color: var(--paper);
  background: var(--ink);
  border-bottom-right-radius: 5px;
}

.from-lamp {
  justify-self: start;
  background:
    radial-gradient(circle at top left, rgba(255, 232, 174, .40), transparent 10rem),
    var(--paper-bright);
  border-bottom-left-radius: 5px;
}

.chat-source {
  color: var(--muted);
  font-family: var(--font-label);
  font-size: .68rem;
  font-weight: 800;
}

.chat-form {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid rgba(23, 23, 23, .18);
}

@media (min-width: 760px) {
  .chat-message {
    max-width: 76%;
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .chat-form .submit-button {
    min-width: 120px;
  }
}

/* ---- the live chat (operator-ruled 2026-07-09): talk to the lamp ---- */
.chat-log {
  display: grid;
  gap: 10px;
  margin: 10px 0;
  max-height: 24rem;
  overflow-y: auto;
  padding: 4px 2px;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
}

.chat-msg .chat-who {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-family: var(--font-control);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.chat-msg p {
  margin: 0;
  white-space: pre-wrap;
}

.chat-user {
  justify-self: end;
  background: rgba(255, 248, 232, .85);
  border: 1px solid rgba(23, 23, 23, .18);
}

.chat-assistant {
  justify-self: start;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--bronze);
}

.chat-assistant .chat-who {
  color: #dfc991;
}

.chat-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chat-reset-form {
  margin-top: 8px;
  text-align: right;
}

.chat-reset {
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(23, 23, 23, .2);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-control);
  font-size: .66rem;
  text-transform: uppercase;
}

/* messenger + workspaces (2026-07-10) */
.chat-peer {
  justify-self: start;
  background: rgba(255, 248, 232, .6);
  border: 1px solid rgba(138, 106, 63, .45);
}

.chat-ws-name {
  margin: 12px 0 4px;
  color: var(--bronze);
  font-family: var(--font-control);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.chat-save-form {
  margin-top: 4px;
  text-align: right;
}

.chat-save {
  padding: 2px 8px;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(23, 23, 23, .18);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-control);
  font-size: .58rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.chat-assistant .chat-save {
  color: #cdb98a;
  border-color: rgba(195, 154, 70, .4);
}

/* ---- multi-chat + live streaming (2026-07-10) ---- */
.chat-chips {
  margin-top: 12px;
}

.chat-new-form {
  display: contents;
}

.chat-new {
  cursor: pointer;
  border-style: dashed;
}

.chat-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.chat-tool-form {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-rename-input {
  max-width: 15rem;
  padding: 6px 8px;
  font-size: .8rem;
}

.chat-tool {
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(23, 23, 23, .2);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-control);
  font-size: .66rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chat-tool-danger {
  color: var(--red);
  border-color: rgba(155, 45, 48, .45);
}

.chat-status,
.chat-doing {
  margin: 4px 0 0;
  color: var(--muted);
  font-family: var(--font-control);
  font-size: .7rem;
  font-style: italic;
}

.chat-assistant .chat-doing {
  color: #cdb98a;
}

.chat-error {
  color: var(--red);
  font-style: italic;
}

.chat-assistant .chat-error {
  color: #f0b8b0;
}

.chat-send-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-stop {
  padding: 10px 14px;
  color: var(--red);
  background: transparent;
  border: 1px solid rgba(155, 45, 48, .45);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-control);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* markdown inside bubbles: the lamp writes like a person, not a printout */
.chat-md > * {
  margin: 0;
}

.chat-md > * + * {
  margin-top: 8px;
}

.chat-md ul,
.chat-md ol {
  padding-left: 1.2rem;
}

.chat-md li + li {
  margin-top: 3px;
}

.chat-md h4,
.chat-md h5,
.chat-md h6 {
  font-size: .9rem;
  letter-spacing: .02em;
}

.chat-md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(23, 23, 23, .1);
  font-size: .85em;
}

.chat-md pre {
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(23, 23, 23, .08);
  overflow-x: auto;
}

.chat-md pre code {
  padding: 0;
  background: none;
}

.chat-md blockquote {
  margin: 0;
  padding-left: 10px;
  border-left: 3px solid rgba(138, 106, 63, .5);
}

.chat-assistant .chat-md code {
  background: rgba(255, 255, 255, .14);
}

.chat-assistant .chat-md pre {
  background: rgba(255, 255, 255, .1);
}

.chat-assistant .chat-md a {
  color: #e8d4a4;
}

/* three quiet dots while the lamp draws breath */
.chat-typing i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: #cdb98a;
  animation: chat-breathe 1.2s infinite ease-in-out;
}

.chat-typing i:nth-child(2) {
  animation-delay: .2s;
}

.chat-typing i:nth-child(3) {
  animation-delay: .4s;
}

@keyframes chat-breathe {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing i {
    animation: none;
  }
}

/* desktop composer: the message is the wide thing, not the project picker
 * (the two-column rule above was shaped for the messenger form) */
@media (min-width: 760px) {
  .chat-form[data-chat-form] {
    grid-template-columns: minmax(10rem, auto) minmax(0, 1fr);
  }

  .chat-form[data-chat-form] .chat-send-row {
    grid-column: 1 / -1;
  }
}

/* ---- the chat bubble + overlay (Lantern Directive era, 2026-07-10):
 * "once in a chat I'm just in a chat window" — a floating bubble that
 * expands into a near-fullscreen dialog over whatever page you're on ---- */
.chat-bubble {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 40;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 232, 174, .35), transparent 2.6rem),
    var(--ink);
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 10px 24px rgba(23, 23, 23, .38);
}

.chat-bubble img {
  width: 28px;
  height: 34px;
}

.chat-overlay {
  width: min(760px, calc(100% - 14px));
  height: 93dvh;
  max-height: 93dvh;
  padding: 0;
  border: none;
  background: transparent;
}

.chat-overlay::backdrop {
  background: rgba(23, 19, 15, .58);
}

.chat-overlay-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, var(--pane-hi), var(--pane-lo));
  border: 1px solid rgba(8, 10, 16, .9);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(23, 19, 15, .4);
}

.chat-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  color: var(--paper);
  background: var(--ink);
  border-bottom: 2px solid var(--gold);
}

.chat-overlay-title {
  margin: 0;
  font-family: var(--font-label);
  font-size: .74rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.chat-overlay-where {
  color: var(--gold);
}

.chat-overlay-close {
  min-width: 40px;
  min-height: 40px;
  color: var(--paper);
  background: transparent;
  border: 1px solid rgba(255, 248, 232, .4);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
}

/* the injected panel fills the window: chips pinned up top, the log is
 * the breathing middle, the composer pinned at the bottom */
.chat-overlay-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 12px;
  overflow-y: auto;
}

.chat-overlay-body > :not(.chat-log) {
  flex: 0 0 auto;    /* only the log breathes — chips/tools keep height */
}

.chat-overlay-body .chat-log {
  flex: 1 1 auto;
  min-height: 8rem;
  max-height: none;
}

.chat-overlay-body .chat-provenance {
  margin: 10px 0 0;
}

.chat-overlay-body .chat-form {
  padding: 10px 0 0;
}
