/* ============ Chat (Gopher) ============ */
/* The narrowest view in the app — it lives in a rail, so the bubbles are sized
   in percentages and the type stays small, and the log takes whatever height is
   left between the head and the composer. */

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #10151c;
  flex-shrink: 0;
}

.chat-avatar .material-symbols-outlined {
  font-size: 17px;
}

.chat-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.chat-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-status {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.chat-clear:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-clear .material-symbols-outlined {
  font-size: 16px;
}

/* ---------- Conversations ---------- */
/* A dropdown rather than a row of pills: the rail is too narrow to show more
   than a couple of titles, and a list keeps every conversation reachable
   however many there are. The trigger names the open conversation; the list
   drops over the transcript instead of taking height from it. */

.chat-history {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-history-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 10.5px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.chat-history-btn:hover,
.chat-history.is-open .chat-history-btn {
  border-color: var(--cardBorders);
  background: var(--bg-mid);
}

.chat-history-label {
  flex: 1;
  min-width: 0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-history-caret {
  font-size: 15px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: transform 0.12s;
}

.chat-history.is-open .chat-history-caret {
  transform: rotate(180deg);
}

.chat-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.chat-new:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-new .material-symbols-outlined {
  font-size: 16px;
}

.chat-history-menu {
  position: absolute;
  top: calc(100% - 2px);
  left: 8px;
  right: 8px;
  z-index: 30;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  background: var(--bg-light);
  border: 1px solid var(--cardBorders);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.chat-history-menu[hidden] {
  display: none;
}

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 5px 6px;
  border: none;
  border-radius: 3px;
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10.5px;
  text-align: left;
  cursor: pointer;
}

.chat-history-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chat-history-item.is-active {
  color: var(--accent);
  font-weight: 600;
}

.chat-history-check {
  font-size: 14px;
  flex-shrink: 0;
  visibility: hidden;
}

.chat-history-item.is-active .chat-history-check {
  visibility: visible;
}

.chat-history-item-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Transcript ---------- */

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-row {
  display: flex;
}

.chat-row.is-you {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 86%;
  padding: 6px 9px;
  border-radius: 10px;
  font-family: var(--font-text);
  font-size: 11.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* You speak in grey and Gopher answers in the accent, so the two are told
   apart by tone rather than by a label. */
.chat-row.is-gopher .chat-bubble {
  background: var(--accent);
  border-bottom-left-radius: 3px;
  color: #10151c;
}

.chat-row.is-you .chat-bubble {
  background: var(--bg-light);
  border-bottom-right-radius: 3px;
  color: var(--text-primary);
}

/* The answer to a header search, or a walkthrough step, keeps drawing the eye:
   it is the thing you asked for, and it arrives in a conversation you were not
   looking at. One flash a second, a few times — the tail is bounded so the
   pulse can never outlast the moment, and the script stops it sooner than this
   when the control it points at is clicked. */
.chat-bubble--flash {
  animation: chat-flash 1s ease-in-out 3;
}

@keyframes chat-flash {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.chat-typing {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 9px 10px;
}

.chat-typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: chat-blink 1.1s infinite ease-in-out;
}

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

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

/* ---------- The pin ---------- */
/* Beside an answer that came from the header search: a way back to the panels
   and ring that answer produced, for once the screen has moved on. */

.chat-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 1px 0 0 5px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-start;
  transition: background 0.1s, color 0.1s;
}

.chat-pin:hover {
  background: var(--bg-hover);
  color: var(--accent-hover);
}

.chat-pin .material-symbols-outlined {
  font-size: 15px;
}

/* The dots sit on the accent now, so they are inked rather than grey. */
.chat-row.is-gopher .chat-typing i {
  background: rgba(16, 21, 28, 0.75);
}

@keyframes chat-blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Composer ---------- */

.chat-compose {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-mid);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 5px 8px;
  border-radius: 999px;
  font-family: var(--font-text);
  font-size: 11.5px;
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input:focus {
  border-color: var(--accent);
}

.chat-send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: #10151c;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-send:hover {
  background: var(--accent-hover);
}

.chat-send .material-symbols-outlined {
  font-size: 15px;
}
