/* Ask Charles chatbot — typography mirrors the rest of the site (Times New
   Roman, 14px, line-height 1.6, same gray Win98 chrome) */

.chat-body {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 10px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: #fff;
  border-top: 1px solid var(--window-border-dark);
  border-left: 1px solid var(--window-border-dark);
  border-right: 1px solid var(--window-border-light);
  border-bottom: 1px solid var(--window-border-light);
  padding: 14px 16px;
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 0;
}

.chat-msg {
  margin-bottom: 14px;
}

.chat-msg:last-child { margin-bottom: 0; }

.chat-msg-role {
  display: inline;
  font-weight: bold;
  font-size: 14px;
  color: #666;
  margin-right: 4px;
}

.chat-msg-charles .chat-msg-role { color: #000080; }
.chat-msg-user .chat-msg-role { color: #800000; }

.chat-msg-role::after { content: ":"; }

.chat-msg-content {
  display: inline;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-msg-content a {
  color: var(--link);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-msg-content p { margin: 0 0 8px 0; }
.chat-msg-content p:last-child { margin-bottom: 0; }

.chat-msg-content code {
  background: #f0f0f0;
  padding: 1px 4px;
  border: 1px solid #d0d0d0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.chat-msg-greeting .chat-msg-content { font-style: italic; color: #333; }

.chat-status {
  font-size: 13px;
  color: #555;
  padding: 0 2px;
  font-style: italic;
  flex-shrink: 0;
  min-height: 20px;
  line-height: 1.6;
}

.chat-status.hidden { display: none; }

.chat-dots {
  display: inline-block;
  animation: chat-dots 1.4s steps(4, end) infinite;
  overflow: hidden;
  vertical-align: bottom;
  width: 1.5em;
}
@keyframes chat-dots {
  0%   { width: 0; }
  100% { width: 1.5em; }
}

.chat-input-form {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: stretch;
}

.chat-input-form textarea {
  flex: 1;
  font-family: 'Times New Roman', Times, serif;
  font-size: 14px;
  line-height: 1.5;
  padding: 6px 8px;
  background: #fff;
  border-top: 1px solid var(--window-border-dark);
  border-left: 1px solid var(--window-border-dark);
  border-right: 1px solid var(--window-border-light);
  border-bottom: 1px solid var(--window-border-light);
  resize: none;
  outline: none;
  color: #000;
}

.chat-input-form textarea:focus { outline: 1px dotted #000; outline-offset: -3px; }

.chat-input-form button {
  align-self: stretch;
  min-width: 80px;
}

.chat-input-form button:disabled {
  color: #808080;
  cursor: not-allowed;
}

.chat-error {
  background: #ffe0e0;
  border: 1px solid #c00;
  color: #800;
  padding: 6px 10px;
  font-size: 13px;
  margin-bottom: 10px;
}

@media (max-width: 768px) {
  .chat-body { padding: 12px; gap: 10px; }
  .chat-messages { font-size: 14px; padding: 12px; }

  /* 16px is the magic number that prevents iOS Safari from auto-zooming
     when the textarea gains focus. Don't drop below this. */
  .chat-input-form textarea {
    font-size: 16px;
    line-height: 1.4;
    padding: 8px 10px;
    min-height: 44px;
  }

  /* iOS Human Interface Guidelines: tap targets >= 44x44 pt */
  .chat-input-form button {
    min-height: 44px;
    min-width: 64px;
    padding: 6px 14px;
  }

  .chat-status { font-size: 13px; }
}
