* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; }
.container { max-width: 960px; margin: 0 auto; padding: 16px; }

header { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; flex-wrap: wrap; gap: 12px; }
header h1 { font-size: 1.5rem; color: #1a1a2e; }
.actions { display: flex; gap: 8px; }

.btn { padding: 8px 16px; border: 1px solid #ddd; border-radius: 6px; background: #fff; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.btn:hover { background: #f5f5f5; }
.btn.primary { background: #4472C4; color: #fff; border-color: #4472C4; }
.btn.primary:hover { background: #365a9e; }
.btn.danger { background: #E74C3C; color: #fff; border-color: #E74C3C; }
.btn.success { background: #27AE60; color: #fff; border-color: #27AE60; }
.btn.warning { background: #F39C12; color: #fff; border-color: #F39C12; }
.btn.sm { padding: 4px 10px; font-size: 0.75rem; }

/* Agent Tabs */
.agent-tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.agent-tab { padding: 8px 18px; border: 2px solid #ddd; border-radius: 8px; background: #fff; cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.agent-tab.active { border-color: #4472C4; background: #4472C4; color: #fff; }
.agent-tab:hover:not(.active) { background: #e8e8e8; }
.agent-tab.active .agent-dot { box-shadow: 0 0 0 2px #fff; }
.agent-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.agent-dot.mimi { background: #3498db; }
.agent-dot.claude { background: #8e44ad; }
.agent-dot.openai { background: #10a37f; }

/* Status Filters */
.filters { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn { padding: 6px 14px; border: 1px solid #ddd; border-radius: 20px; background: #fff; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.filter-btn.active { background: #4472C4; color: #fff; border-color: #4472C4; }
.filter-btn:hover:not(.active) { background: #e8e8e8; }

.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-card { background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); cursor: pointer; transition: all 0.2s; border-left: 4px solid #ddd; }
.task-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); transform: translateY(-1px); }
.task-card.status-pending { border-left-color: #95a5a6; }
.task-card.status-in_progress { border-left-color: #3498db; }
.task-card.status-in_review { border-left-color: #f39c12; }
.task-card.status-rework { border-left-color: #e74c3c; }
.task-card.status-approved { border-left-color: #27ae60; }
.task-card.status-on_hold { border-left-color: #e67e22; }

.task-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.task-id { font-weight: 700; font-size: 0.95rem; }
.task-time { font-size: 0.75rem; color: #999; }
.task-prompt { font-size: 0.85rem; color: #555; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-agent-comment { font-size: 0.8rem; color: #444; background: #f4f6fb; border-left: 3px solid #4472C4; padding: 5px 8px; border-radius: 0 4px 4px 0; margin-bottom: 8px; line-height: 1.4; word-break: break-word; }
.agent-comment-label { font-weight: 700; color: #4472C4; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.task-bottom { display: flex; justify-content: space-between; align-items: center; }

/* Badges */
.status-badge { padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; color: #fff; }
.status-badge.pending { background: #95a5a6; }
.status-badge.in_progress { background: #3498db; }
.status-badge.in_review { background: #f39c12; }
.status-badge.rework { background: #e74c3c; }
.status-badge.approved { background: #27ae60; }
.status-badge.on_hold { background: #e67e22; }

.agent-badge { padding: 3px 10px; border-radius: 12px; font-size: 0.7rem; font-weight: 600; color: #fff; }
.agent-badge.mimi { background: #3498db; }
.agent-badge.claude { background: #8e44ad; }
.agent-badge.openai { background: #10a37f; }

.task-btns { display: flex; gap: 6px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; justify-content: center; align-items: flex-start; padding: 40px 16px; overflow-y: auto; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 780px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eee; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-header h2 { font-size: 1.1rem; }
.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; }
.close-btn:hover { color: #333; }
.modal-body { padding: 20px; }

label { display: block; font-size: 0.8rem; font-weight: 600; color: #555; margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input[type="text"], input[type="email"], textarea, select { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
textarea { resize: vertical; }
.agent-comment-textarea { font-size: 0.85rem; background: #f4f6fb; border-color: #4472C4; line-height: 1.5; color: #222; }
select { background: #fff; }

.comment-list { margin: 12px 0; max-height: 200px; overflow-y: auto; }
.comment-item { padding: 8px; border-bottom: 1px solid #f0f0f0; font-size: 0.85rem; }
.comment-item .author { font-weight: 600; color: #4472C4; }
.comment-item .time { font-size: 0.7rem; color: #aaa; }
.comment-input { display: flex; gap: 8px; margin-top: 8px; }
.comment-input input { flex: 1; }
.comment-input select { width: auto; flex: 0 0 100px; }

.file-section { margin-top: 12px; padding: 12px; background: #f8f9fa; border-radius: 6px; }
.file-section input[type="file"] { font-size: 0.8rem; }

@media (max-width: 600px) {
  .container { padding: 10px; }
  header h1 { font-size: 1.2rem; }
  .agent-tabs { gap: 3px; }
  .agent-tab { padding: 6px 12px; font-size: 0.8rem; }
  .filters { gap: 4px; }
  .filter-btn { padding: 5px 10px; font-size: 0.7rem; }
  .modal { margin: 10px; }
  .task-btns { flex-direction: column; gap: 4px; }
  .chat-modal { height: 92vh; }
}

/* ── Chat Button ── */
.btn.chat-btn { background: #3498db; color: #fff; border-color: #3498db; }
.btn.chat-btn:hover { background: #2176ae; }

/* ── Chat Modal ── */
#chat-overlay .modal.chat-modal {
  max-width: 700px;
  height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chat-overlay .modal-body { display: none; } /* unused in chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f9fc;
}
.chat-empty {
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
  margin: auto;
  padding: 40px 20px;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 3px;
}
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.mimi  { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: #4472C4;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.chat-msg.mimi .chat-bubble {
  background: #fff;
  color: #1a1a2e;
  border-radius: 16px 16px 16px 4px;
  border-left: 3px solid #3498db;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.chat-bubble.thinking { color: #999; font-style: italic; }
.chat-ts { font-size: 0.7rem; color: #bbb; padding: 0 4px; }
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}
.chat-input-bar textarea {
  flex: 1;
  resize: none;
  height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid #ddd;
  font-family: inherit;
  line-height: 1.4;
}
.chat-input-bar textarea:focus { outline: none; border-color: #4472C4; }
.chat-send-btn { align-self: flex-end; height: 48px; padding: 0 20px; border-radius: 10px; font-size: 0.9rem; }
