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

:root {
  --bg: #f5f5f0;
  --chat-bg: #ffffff;
  --panel-bg: #fafaf7;
  --accent: #2d5a27;
  --accent-light: #e8f0e6;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e0ddd5;
  --card-bg: #ffffff;
  --user-bubble: #2d5a27;
  --user-text: #ffffff;
  --bot-bubble: #f0ede5;
  --bot-text: #1a1a1a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  border-right: 1px solid var(--border);
  min-width: 0;
}

.chat-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.chat-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.chat-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 85%;
  animation: fadeUp 0.25s ease;
}

.message.user {
  align-self: flex-end;
}

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

.message-bubble {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--bot-bubble);
  color: var(--bot-text);
  border-bottom-left-radius: 4px;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 12px 16px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

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

/* Chat input */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--chat-bg);
}

.chat-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input textarea:focus {
  border-color: var(--accent);
}

.chat-input button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.chat-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-input button:hover:not(:disabled) {
  opacity: 0.85;
}

/* OCAI panel */
.ocai-panel {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  overflow-y: auto;
}

.ocai-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.ocai-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* Stepper */
.stepper {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  position: relative;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 28px;
  bottom: -8px;
  width: 2px;
  background: var(--border);
}

.step.completed:not(:last-child)::after {
  background: var(--accent);
}

.step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--panel-bg);
  flex-shrink: 0;
  transition: all 0.3s;
  position: relative;
  z-index: 1;
}

.step.active .step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.step.completed .step-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.step-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: color 0.3s;
}

.step.active .step-label {
  color: var(--accent);
  font-weight: 600;
}

.step.completed .step-label {
  color: var(--text);
  font-weight: 500;
}

/* OCAI cards */
.ocai-cards {
  flex: 1;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.welcome-card {
  padding: 20px;
  background: var(--accent-light);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.ocai-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.4s ease;
}

.ocai-card.highlight {
  border-color: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--accent);
}

.ocai-card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}

.ocai-card-content {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
}

.ocai-card-content ul {
  list-style: none;
  padding: 0;
}

.ocai-card-content ul li {
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.ocai-card-content ul li::before {
  content: "\2022";
  color: var(--accent);
  font-weight: bold;
  position: absolute;
  left: 0;
}

/* Generate button */
.generate-btn {
  margin: 0 24px 24px;
  padding: 12px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.generate-btn:hover {
  opacity: 0.9;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-body pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
}

.copy-btn {
  margin: 0 24px 20px;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn:hover {
  opacity: 0.9;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .chat-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: 60vh;
  }

  .ocai-panel {
    width: 100%;
    height: 40vh;
  }
}
