* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color: #e2e8f0;
  height: 100vh;
  overflow: hidden;
}
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
  gap: 10px;
  min-height: 56px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hamburger {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s;
  line-height: 1;
}
.hamburger:hover { background: #334155; }
.header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-title-small {
  font-size: 0.7rem;
  color: #64748b;
  -webkit-text-fill-color: #64748b;
  font-weight: 400;
  margin-left: 4px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn {
  background: #334155;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #475569; }
.btn-primary { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); }
.btn-success:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-sm { padding: 4px 10px; font-size: 0.7rem; }
.btn:disabled { opacity: 0.4; pointer-events: none; filter: grayscale(0.3); }

/* ===== SETUP PANEL ===== */
.setup-panel {
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 12px 16px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 420px;
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}
.setup-panel.collapsed {
  max-height: 0;
  padding: 0 16px;
  opacity: 0;
  overflow: hidden;
}
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
@media (max-width: 768px) {
  .setup-grid { grid-template-columns: 1fr; }
}
.setup-section {
  background: #0f172a;
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid #334155;
}
.setup-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.setup-section h3 .step-num {
  background: #334155;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 0.6rem;
  color: #64748b;
  line-height: 18px;
}
.setup-section h3 .step-num.done { background: #10b981; color: white; }
.setup-section h3 .step-num.active { background: #8b5cf6; color: white; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.setup-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.setup-row input {
  flex: 1;
  min-width: 100px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 10px;
  color: #e2e8f0;
  font-size: 0.75rem;
}
.setup-row input:focus { border-color: #8b5cf6; outline: none; }
.setup-status {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 4px;
}
.setup-status .ok { color: #10b981; }
.setup-status .err { color: #ef4444; }
.setup-status .wait { color: #fbbf24; }
.cell-output-preview {
  background: #0a111f;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  color: #94a3b8;
  max-height: 70px;
  overflow-y: auto;
  margin-top: 4px;
  border: 1px solid #1e293b;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}
.repo-display {
  font-size: 0.7rem;
  color: #94a3b8;
  padding: 2px 10px;
  background: #0f172a;
  border-radius: 10px;
  border: 1px solid #334155;
  display: inline-block;
  margin-top: 4px;
}

/* ===== CHAT AREA ===== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  min-height: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages .empty {
  color: #475569;
  text-align: center;
  padding: 30px 20px;
  font-size: 0.85rem;
}
.msg {
  background: #1e293b;
  border-radius: 14px;
  padding: 10px 14px;
  max-width: 88%;
  word-break: break-word;
  line-height: 1.5;
  font-size: 0.88rem;
  animation: slideUp 0.15s ease-out;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg.user { align-self: flex-end; background: #2d3b52; border-bottom-right-radius: 4px; }
.msg.user .label { color: #a78bfa; font-weight: 600; font-size: 0.65rem; }
.msg.bot { align-self: flex-start; background: #1e293b; border-bottom-left-radius: 4px; border-left: 3px solid #8b5cf6; }
.msg.bot .label { color: #10b981; font-weight: 600; font-size: 0.65rem; }
.msg.bot.simple { border-left-color: #f59e0b; }
.msg .content { margin-top: 3px; white-space: pre-wrap; }
.msg .content .streaming { 
  display: inline-block;
  animation: blink 0.8s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.msg .content .partial { color: #94a3b8; }

.chat-input-area {
  padding: 10px 16px 14px;
  background: #1e293b;
  border-top: 1px solid #334155;
  flex-shrink: 0;
}
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.chat-input-row input {
  flex: 1;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px 14px;
  color: #e2e8f0;
  font-size: 0.85rem;
  min-height: 40px;
}
.chat-input-row input:focus { border-color: #8b5cf6; outline: none; }
.chat-input-row input:disabled { opacity: 0.4; }
.chat-btn-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}
.chat-btn-group .btn {
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.7rem;
  justify-content: center;
  width: 100%;
}
.chat-input-row .btn-primary { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.chat-input-row .btn-secondary { background: #334155; }
.chat-input-row .btn-secondary:hover:not(:disabled) { background: #475569; }

.chat-status {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 4px;
  text-align: center;
}
.chat-status .ok { color: #10b981; }
.chat-status .err { color: #ef4444; }
.chat-status .wait { color: #fbbf24; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }
