.chatui-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-height: 0;
  background: transparent;
}

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

.chat-empty-state {
  margin: auto;
  max-width: 240px;
  text-align: center;
  color: var(--subtext);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.chat-empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.10);
  border: 1px solid rgba(210, 187, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-soft);
  box-shadow: inset 0 -8px 24px rgba(124, 58, 237, 0.08);
}

.chat-empty-state h3 {
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0;
}

.chat-empty-state p {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
  color: var(--subtext);
}

.chat-bubble {
  max-width: min(780px, 88%);
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  min-width: 0;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(137, 180, 250, 0.18), rgba(203, 166, 247, 0.18));
  border-color: rgba(137, 180, 250, 0.35);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface0);
}

.chat-bubble.assistant.working {
  border-color: rgba(249, 226, 175, 0.35);
  background: var(--surface0);
}

.chat-meta {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--subtext0);
  margin-bottom: 8px;
}

.chat-working {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 14px;
}

.chat-working-label {
  color: var(--subtext);
}

.chat-working-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-working-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(249, 226, 175, 0.9);
  animation: chat-working-pulse 1s infinite ease-in-out;
}

.chat-working-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.chat-working-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.6;
  font-size: 14px;
  color: var(--text);
}

.chat-markdown {
  font-size: 14px;
  min-width: 0;
}

.chat-markdown.markdown-body p,
.chat-markdown.markdown-body li,
.chat-markdown.markdown-body td {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chat-markdown.markdown-body pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
}

.chat-markdown.markdown-body :not(pre) > code {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.chat-markdown.markdown-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.chat-markdown.markdown-body h1,
.chat-markdown.markdown-body h2,
.chat-markdown.markdown-body h3 {
  margin-top: 0;
}

.chat-system {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface0);
  color: var(--subtext);
  font-size: 12px;
}

.chat-system.error {
  background: rgba(243, 139, 168, 0.16);
  color: var(--red);
}

.permission-chip {
  align-self: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(249, 226, 175, 0.16);
  border: 1px solid rgba(249, 226, 175, 0.28);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 600;
}

.chat-composer {
  border-top: 1px solid var(--border-soft);
  background: var(--glass-input);
  padding: 14px 16px 16px;
  position: relative;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.chat-composer-input {
  min-height: 84px;
  resize: none;
  background: var(--crust);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
}
.chat-composer-input::placeholder { color: var(--subtext0); }

.chat-command-suggestions {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--mantle);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.chat-command-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext0);
}

.chat-command-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}

.chat-command-item {
  appearance: none;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: inherit;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.chat-command-item:first-child {
  border-top: 0;
}

.chat-command-item:hover,
.chat-command-item.active {
  background: var(--surface0);
}

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

.chat-command-desc {
  font-size: 12px;
  line-height: 1.45;
  color: var(--subtext);
}

.chat-command-hint {
  font-size: 11px;
  color: var(--subtext0);
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.chat-composer-hint {
  font-size: 12px;
  color: var(--subtext0);
  margin-left: auto;
}

.chat-new-btn {
  flex: 0 0 auto;
}

#chat-composer-send {
  flex: 0 0 auto;
}

@keyframes chat-working-pulse {
  0%, 80%, 100% {
    transform: scale(0.72);
    opacity: 0.35;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .chat-bubble {
    max-width: 94%;
  }

  .chat-composer-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
