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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app-container {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  height: 90dvh;
  max-height: 800px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  overflow: hidden;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e5e5e5;
  min-width: 0;
}

.command-section {
  width: 400px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.command-section.hidden {
  width: 0;
  overflow: hidden;
}

/* Header */
.header {
  padding: 20px;
  border-bottom: 1px solid #e5e5e5;
  background: white;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}

.title {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.model-selector {
  padding: 8px 12px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: #1a1a1a;
  background: white;
  cursor: pointer;
  outline: none;
  max-width: 180px;
}

.model-selector:focus {
  border-color: #3b82f6;
}

.clear-btn {
  padding: 8px 16px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: #f5f5f5;
  border-color: #999;
}

.console-link {
  padding: 8px 12px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  font-size: 13px;
  background: #f0f0f0;
  color: #666;
  text-decoration: none;
  transition: all 0.2s;
}

.console-link:hover {
  background: #e0e0e0;
  border-color: #999;
  color: #333;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.status-indicator.offline {
  background: #ef4444;
}

/* Messages */
.messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
}

.messages-area::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb {
  background: #d1d1d1;
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

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

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  color: white;
}

.message.assistant .message-avatar {
  background: #3b82f6;
}

.message.user .message-avatar {
  background: #6366f1;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.assistant .message-bubble {
  background: #f5f5f5;
  color: #1a1a1a;
}

.message.user .message-bubble {
  background: #3b82f6;
  color: white;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

.message-actions {
  margin-top: 4px;
  padding: 0 4px;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #666;
}

.copy-btn:hover {
  background: #e5e5e5;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  gap: 12px;
  align-items: center;
  padding: 0 20px;
}

.typing-indicator.active {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f5f5f5;
  border-radius: 8px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* Input area */
.input-area {
  padding: 20px;
  border-top: 1px solid #e5e5e5;
  background: white;
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #d1d1d1;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 120px;
}

.message-input:focus {
  border-color: #3b82f6;
}

.send-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  height: 48px;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #2563eb;
}

.send-btn:active {
  transform: scale(0.98);
}

.send-btn:disabled {
  background: #d1d1d1;
  cursor: not-allowed;
}

/* Command Section */
.command-header {
  padding: 20px;
  border-bottom: 1px solid #e5e5e5;
  background: white;
}

.command-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.command-subtitle {
  font-size: 13px;
  color: #666;
}

.command-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.command-content::-webkit-scrollbar {
  width: 6px;
}

.command-content::-webkit-scrollbar-track {
  background: transparent;
}

.command-content::-webkit-scrollbar-thumb {
  background: #d1d1d1;
  border-radius: 3px;
}

.command-item {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.command-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}

.command-status {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 8px;
}

.command-status.running {
  background: #dbeafe;
  color: #1e40af;
}

.command-status.completed {
  background: #d1fae5;
  color: #065f46;
}

.command-status.error {
  background: #fee2e2;
  color: #991b1b;
}

.command-details {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  white-space: pre-wrap;
  background: #f9f9f9;
  padding: 8px;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.command-time {
  font-size: 11px;
  color: #999;
  margin-top: 8px;
}

.empty-state {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

/* Code blocks in messages */
.message-bubble pre {
  background: #1a1a1a;
  color: #e5e5e5;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-bubble code {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

.message-bubble pre code {
  background: none;
  padding: 0;
}

.message-bubble code:not(pre code) {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.message.user .message-bubble code:not(pre code) {
  background: rgba(255, 255, 255, 0.2);
}

/* CMD lines - not read aloud */
.cmd-line {
  color: #dc2626;
  font-style: italic;
}

/* Command toggle button for mobile */
.command-toggle {
  display: none;
  padding: 8px 12px;
  border: 1px solid #d1d1d1;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.command-toggle:hover {
  background: #f5f5f5;
  border-color: #999;
}

.command-toggle.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* Tablet */
@media (max-width: 1024px) {
  .command-section {
    width: 300px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .app-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .chat-section {
    flex: 1;
    border-right: none;
    min-height: 0;
  }

  /* Header adjustments */
  .header {
    padding: 12px 16px;
  }

  .header-top {
    flex-wrap: wrap;
    gap: 8px;
  }

  .title {
    font-size: 16px;
    flex: 1;
    min-width: 100px;
  }

  .controls {
    gap: 8px;
    flex-wrap: wrap;
  }

  .model-selector {
    padding: 10px 12px;
    font-size: 14px;
    max-width: 140px;
    flex: 1;
    min-width: 100px;
  }

  .clear-btn {
    padding: 10px 12px;
  }

  .command-toggle {
    display: block;
  }

  .status {
    width: 100%;
    margin-top: 4px;
  }

  /* Messages */
  .messages-area {
    padding: 12px;
    gap: 12px;
  }

  .message {
    max-width: 88%;
    gap: 8px;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 15px;
  }

  /* Input area */
  .input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .input-wrapper {
    gap: 8px;
  }

  .message-input {
    padding: 12px 14px;
    font-size: 16px;
    min-height: 44px;
  }

  .send-btn {
    padding: 12px 16px;
    height: 44px;
    font-size: 14px;
  }

  /* Command section - slide up from bottom */
  .command-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 50vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 100;
  }

  .command-section.visible {
    transform: translateY(0);
  }

  .command-section.hidden {
    width: 100%;
    max-height: 0;
    transform: translateY(100%);
  }

  .command-header {
    padding: 16px;
    cursor: pointer;
    position: relative;
  }

  .command-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: #d1d1d1;
    border-radius: 2px;
  }

  .command-content {
    padding: 12px 16px;
    max-height: calc(50vh - 80px);
  }

  .typing-indicator {
    padding: 0 12px;
  }
}

/* Small mobile */
@media (max-width: 380px) {
  .header-top {
    flex-direction: column;
    align-items: stretch;
  }

  .title {
    text-align: center;
    margin-bottom: 8px;
  }

  .controls {
    justify-content: center;
  }

  .model-selector {
    max-width: none;
    flex: 1;
  }

  .message {
    max-width: 92%;
  }

  .message-avatar {
    display: none;
  }

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