:root {
  color-scheme: light;
  font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --chat-bg: #0f172a;
  --chat-panel: #ffffff;
  --chat-border: #e5e7eb;
  --chat-muted: #6b7280;
  --chat-accent: #4f46e5;
  --chat-accent-soft: rgba(79, 70, 229, 0.1);
  --chat-user: #111827;
  --chat-assistant: #0f172a;
  --chat-assistant-bg: #eef2ff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f3f4f6;
  color: var(--chat-user);
  display: flex;
  justify-content: center;
  padding: 16px;
  height: 100vh;
}

.chat-shell {
  width: 100%;
  max-width: 720px;
  min-height: 100%;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
}


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

.chat-message {
  display: flex;
  gap: 12px;
}

.chat-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #374151;
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.chat-message-body {
  background: #f3f4f6;
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 90%;
  line-height: 1.5;
  white-space: pre-wrap;
}

.chat-message-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.chat-inline-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--chat-accent);
  color: white;
}

.chat-inline-btn:hover {
  opacity: 0.9;
}

.chat-message-user {
  flex-direction: row-reverse;
}

.chat-message-user .chat-message-avatar {
  background: var(--chat-accent);
}

.chat-message-user .chat-message-body {
  background: #eef2ff;
  color: var(--chat-user);
}

.chat-message-assistant .chat-message-body {
  background: var(--chat-assistant-bg);
  color: var(--chat-assistant);
}

.chat-code-block {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.4;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 10px;
  border: 1px solid #1e293b;
  padding: 12px;
  margin-top: 12px;
  white-space: pre;
  width: 100%;
  max-width: 100%;
  max-height: 200px;
  overflow: auto;
}

.chat-code-block.scrollable {
  max-height: 200px;
}

.chat-code-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-code-actions .chat-inline-btn {
  background: #1d4ed8;
  font-size: 12px;
}

.chat-code-actions .chat-inline-btn.secondary {
  background: transparent;
  color: #1d4ed8;
  border: 1px solid rgba(29, 78, 216, 0.4);
}

.chat-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--chat-muted);
}

footer {
  padding: 16px 20px;
  border-top: 1px solid var(--chat-border);
  background: #fff;
}

.chat-composer {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#chatInput {
  flex: 1;
  border-radius: 10px;
  border: 1px solid var(--chat-border);
  padding: 12px 16px;
  font-family: inherit;
  resize: none;
  min-height: 48px;
}

.chat-primary-btn,
.chat-secondary-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.chat-primary-btn {
  background: var(--chat-accent);
  color: white;
}

.chat-primary-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.chat-primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.chat-secondary-btn {
  background: var(--chat-accent-soft);
  color: var(--chat-accent);
}

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .chat-shell {
    border-radius: 0;
    border-left: none;
    border-right: none;
    height: 100vh;
  }
}
