:root {
  --chat-text: #202122;
  --chat-link: #3366cc;
  --chat-border: #a2a9b1;
  --chat-border-soft: #eaecf0;
  --chat-muted: #54595d;
  --chat-panel: #f8f9fa;
  --chat-white: #ffffff;
}

.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0 54px, rgba(32, 33, 34, .46) 54px 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.chat-overlay.is-open {
  opacity: 1;
}

.chat-panel {
  width: min(640px, 100%);
  height: calc(100vh - 54px);
  margin: 54px auto 0;
  background: var(--chat-white);
  color: var(--chat-text);
  border-left: 1px solid var(--chat-border-soft);
  border-right: 1px solid var(--chat-border-soft);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  opacity: 0;
  outline: 0;
  pointer-events: auto;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

#chat-panel:empty {
  display: none;
}

.chat-overlay.is-open .chat-panel {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.chat-panel-shell {
  min-height: 0;
  width: 100%;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.chat-panel-header {
  border-bottom: 1px solid var(--chat-border-soft);
  padding: 14px 18px;
  background: var(--chat-white);
}

.chat-title {
  margin: 0;
  color: var(--chat-text);
  font-family: "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1.2;
}

.chat-panel-body {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  background: var(--chat-white);
}

.chat-error,
.chat-status {
  min-height: 44px;
  padding: 12px 18px;
  color: #a55858;
  font-size: 15px;
  line-height: 1.35;
}

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

.user-picker {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 12px;
  padding: 18px;
}

.chat-user-button,
.hhmm-input button,
.chat-compose button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--chat-border);
  background: var(--chat-panel);
  color: var(--chat-text);
  cursor: pointer;
  font: 600 16px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.chat-user-button {
  flex: 1 1 0;
  width: 50%;
  min-height: 58px;
  font-size: 22px;
}

.chat-user-button:hover,
.hhmm-input button:hover,
.chat-compose button:hover {
  background: #eaecf0;
}

.chat-user-button:disabled,
.hhmm-input button:disabled,
.chat-compose button:disabled,
.hhmm-input input:disabled,
.chat-compose textarea:disabled {
  cursor: default;
  opacity: .62;
}

.hhmm-input {
  display: flex;
  gap: 10px;
  padding: 18px;
}

.hhmm-input input {
  min-width: 0;
  min-height: 44px;
  flex: 1;
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  font: 18px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
  padding: 9px 11px;
}

.hhmm-input button {
  padding: 0 16px;
}

.chat-surface {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 18px;
  background: var(--chat-white);
}

.chat-messages {
  min-height: 100%;
}

.chat-message {
  margin: 12px 0 12px 18px;
  border-left: 3px solid var(--chat-border-soft);
  padding: 8px 0 8px 14px;
  color: var(--chat-text);
  font-family: "Linux Libertine", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.55;
}

.chat-message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-sig {
  margin-top: 6px;
  color: var(--chat-muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.chat-compose {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--chat-border-soft);
  padding: 10px 12px;
  background: var(--chat-panel);
}

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

.chat-compose textarea {
  min-width: 0;
  min-height: 44px;
  max-height: 128px;
  flex: 1;
  resize: vertical;
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 9px 10px;
}

.chat-compose button {
  padding: 0 16px;
}

@media (max-width: 720px) {
  .chat-panel {
    border-left: 0;
    border-right: 0;
    width: 100%;
  }

  .user-picker,
  .hhmm-input,
  .chat-compose {
    gap: 8px;
    padding-left: 16px;
    padding-right: 16px;
  }
}
