:root {
  --bg: #f7f9fc;
  --bg-elevated: #ffffff;
  --bg-soft: #eef2f7;
  --border: #d8e0ea;
  --text: #1a2332;
  --text-muted: #5c6b7e;
  --accent: #2ca01c;
  --accent-hover: #248a17;
  --accent-soft: rgba(44, 160, 28, 0.1);
  --user-bubble: #2563eb;
  --user-text: #ffffff;
  --assistant-bubble: #ffffff;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow);
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #1f7a14);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  box-shadow: 0 4px 12px rgba(44, 160, 28, 0.25);
}

.brand h1,
.chat-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.brand p,
.chat-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  transition: 0.2s ease;
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-send {
  min-width: 92px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  height: 48px;
}

.btn-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.welcome-card,
.message {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.suggestions {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.suggestions h2 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.suggestions-list {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.suggestion-btn {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: 1.4;
}

.suggestion-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.messages {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 24px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-card {
  padding: 24px;
  border-radius: var(--radius);
  max-width: 720px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.welcome-card h3 {
  margin-top: 0;
  color: var(--text);
}

.welcome-card p {
  color: var(--text-muted);
}

.message {
  max-width: 85%;
  padding: 16px 18px;
  border-radius: var(--radius);
  line-height: 1.6;
  animation: fadeIn 0.25s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b82f6, var(--user-bubble));
  border-color: transparent;
  color: var(--user-text);
}

.message.user .message-meta {
  color: rgba(255, 255, 255, 0.85);
}

.message.assistant {
  align-self: flex-start;
  background: #ffffff;
}

.message.error {
  border-color: #fecaca;
  background: #fef2f2;
}

.message-meta {
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-content p {
  margin: 0 0 0.8rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 0.4rem 0 0.8rem 1.2rem;
}

.message-content code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text);
}

.typing-indicator {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px 28px 24px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

#message-input {
  resize: none;
  min-height: 48px;
  max-height: 180px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}

#message-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
  }

  .sidebar {
    height: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .chat-panel {
    height: auto;
    min-height: 0;
  }

  .suggestions-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .chat-header,
  .messages,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .message {
    max-width: 100%;
  }

  .suggestions-list {
    grid-template-columns: 1fr;
  }
}
