/* === Tasks Index === */

@keyframes worker-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Page Layout --- */
.tasks-container {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* --- Page Header --- */
.tasks-page-header {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.tasks-page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.tasks-header-subtitle {
  color: #6b7280;
  font-size: 0.85rem;
}

.tasks-header-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.tasks-btn {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}

.tasks-btn-primary { background: #4f46e5; color: white; }
.tasks-btn-success { background: #10b981; color: white; }
.tasks-btn-warning { background: #d97706; color: white; }
.tasks-btn-muted   { background: #9ca3af; color: white; }
.tasks-btn-gray    { background: #6b7280; color: white; }

/* --- Flash Messages --- */
.tasks-flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.tasks-flash-notice {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.tasks-flash-alert {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

/* --- Summary Bar (Stats + Workers combined) --- */
.tasks-summary {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.tasks-summary-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
}

.tasks-summary-stat {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.tasks-summary-stat--alert {
  background: #fef2f2;
  padding: 0.125rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #fca5a5;
}

.tasks-summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.tasks-summary-value small {
  font-size: 0.7rem;
  font-weight: 500;
}

.tasks-summary-value--primary { color: #4f46e5; }
.tasks-summary-value--slate   { color: #94a3b8; }
.tasks-summary-value--blue    { color: #3b82f6; }
.tasks-summary-value--green   { color: #10b981; }
.tasks-summary-value--amber   { color: #f59e0b; }
.tasks-summary-value--emerald { color: #059669; }
.tasks-summary-value--violet  { color: #8b5cf6; }
.tasks-summary-value--cyan    { color: #0891b2; }
.tasks-summary-value--red     { color: #dc2626; }

.tasks-summary-label {
  font-size: 0.7rem;
  color: #6b7280;
  font-weight: 500;
}

.tasks-summary-divider {
  width: 1px;
  height: 1.5rem;
  background: #e5e7eb;
  flex-shrink: 0;
}

.tasks-summary-workers {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-left: 0.75rem;
  border-left: 1px solid #e5e7eb;
}

.tasks-summary-worker-label {
  font-size: 0.8rem;
  color: #475569;
  font-weight: 500;
}

.tasks-summary-worker-active { color: #22c55e; }
.tasks-summary-worker-pending { color: #f59e0b; }
.tasks-summary-worker-sep { color: #d1d5db; }

.tasks-summary-worker-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.tasks-worker-tag {
  font-size: 0.7rem;
  padding: 0.0625rem 0.375rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

.tasks-worker-tag--active { background: #22c55e; color: white; }
.tasks-worker-tag--pending { background: #fef3c7; color: #92400e; }

/* --- Search & Filter --- */
.tasks-filter-bar {
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.tasks-filter-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.tasks-filter-input {
  flex: 1;
  min-width: 180px;
  padding: 0.375rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
}

.tasks-filter-select {
  padding: 0.375rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
  background: white;
}

.tasks-filter-clear {
  color: #6b7280;
  font-size: 0.8rem;
  text-decoration: underline;
}

/* --- Two-Column Main Layout --- */
.tasks-main-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.25rem;
  align-items: start;
}

.tasks-main-content {
  min-width: 0;
}

/* --- Sidebar --- */
.tasks-sidebar {
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.tasks-sidebar-tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 0.75rem;
}

.tasks-sidebar-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: none;
  cursor: pointer;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tasks-sidebar-tab:hover {
  color: #374151;
}

.tasks-sidebar-tab--active {
  color: #4f46e5;
  border-bottom-color: #4f46e5;
}

.tasks-sidebar-panel {
  display: block;
}

.tasks-sidebar-panel--hidden {
  display: none;
}

/* --- Sidebar Sections (collapsible) --- */
.tasks-sidebar-section {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.tasks-sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  user-select: none;
}

.tasks-sidebar-section-header:hover {
  opacity: 0.85;
}

.tasks-sidebar-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

.tasks-section-toggle {
  font-size: 0.7rem;
  color: inherit;
  opacity: 0.7;
  transition: transform 0.2s;
}

.tasks-sidebar-section-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.tasks-sidebar-section-body.expanded {
  max-height: 2000px;
}

.tasks-sidebar-section-body.collapsed {
  max-height: 0 !important;
}

.tasks-sidebar-section-content {
  padding: 0.75rem;
  padding-top: 0;
}

/* --- AI Analysis Section --- */
.tasks-sidebar-section--ai {
  border-color: #c7d2fe;
}

.tasks-sidebar-section--ai .tasks-sidebar-section-header {
  background: #f0f4ff;
  color: #3730a3;
}

.tasks-sidebar-section--ai .tasks-sidebar-section-body {
  background: #f0f4ff;
}

.tasks-sidebar-section--ai .tasks-sidebar-section-content {
  padding-top: 0.75rem;
}

.tasks-ai-description {
  color: #6366f1;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.tasks-ai-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tasks-ai-textarea {
  width: 100%;
  min-height: 70px;
  padding: 0.5rem;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 0.8rem;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}

.tasks-ai-submit {
  background: #4f46e5;
  color: white;
  padding: 0.375rem 1rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
  align-self: flex-end;
}

/* --- Manager Chat Section --- */
.tasks-sidebar-section--manager {
  border-color: #333;
}

.tasks-sidebar-section--manager .tasks-sidebar-section-header {
  background: #1e1e1e;
  color: #10b981;
}

.tasks-sidebar-section--manager .tasks-sidebar-section-body {
  background: #1e1e1e;
}

.tasks-sidebar-section--manager .tasks-sidebar-section-content {
  padding-top: 0.75rem;
}

.tasks-manager-panels {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tasks-manager-chat-panel {
  display: flex;
  flex-direction: column;
}

.tasks-manager-terminal-panel {
  display: flex;
  flex-direction: column;
}

.tasks-chat-messages {
  max-height: 300px;
  min-height: 150px;
  overflow-y: auto;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.5rem;
  background: #0d1117;
  margin-bottom: 0.5rem;
}

.tasks-chat-empty {
  color: #6b7280;
  font-size: 0.8rem;
  text-align: center;
  margin-top: 1.5rem;
}

.tasks-chat-msg {
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.375rem;
  font-size: 0.8rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.tasks-chat-msg--user {
  background: #1e3a5f;
  margin-left: 15%;
  text-align: right;
}

.tasks-chat-msg--user .tasks-chat-meta { color: #8b9dc3; }
.tasks-chat-msg--user .tasks-chat-text { color: #e2e8f0; }

.tasks-chat-msg--assistant {
  background: #1a2e1a;
  margin-right: 15%;
}

.tasks-chat-msg--assistant .tasks-chat-meta { color: #6ee7b7; }
.tasks-chat-msg--assistant .tasks-chat-text { color: #d1fae5; }

.tasks-chat-meta {
  font-size: 0.7rem;
  margin-bottom: 0.0625rem;
}

.tasks-chat-text--truncated {
  max-height: 4.5em;
  overflow: hidden;
  position: relative;
}

.tasks-chat-expand {
  font-size: 0.7rem;
  color: #6ee7b7;
  text-decoration: underline;
  cursor: pointer;
}

.tasks-chat-input-row {
  display: flex;
  gap: 0.375rem;
}

.tasks-chat-input {
  flex: 1;
  padding: 0.375rem 0.5rem;
  border: 1px solid #555;
  border-radius: 6px;
  font-size: 0.8rem;
  background: #0d1117;
  color: #c9d1d9;
}

.tasks-chat-send-btn {
  background: #10b981;
  color: white;
  border: none;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.tasks-terminal-pre {
  background: #0d1117;
  color: #c9d1d9;
  padding: 0.5rem;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  max-height: 250px;
  min-height: 100px;
  overflow-y: auto;
}

.tasks-terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.tasks-terminal-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
}

.tasks-terminal-countdown {
  font-size: 0.7rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

/* --- Activities Section (in sidebar) --- */
.tasks-sidebar-section--activities {
  border: none;
}

.tasks-sidebar-activities-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.75rem;
}

.tasks-sidebar-activities-count {
  font-weight: 400;
  font-size: 0.8rem;
  color: #9ca3af;
}

.tasks-activity-timeline {
  position: relative;
  padding-left: 1.25rem;
}

.tasks-activity-timeline::before {
  content: '';
  position: absolute;
  left: 0.375rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}

.tasks-activity-item {
  position: relative;
  margin-bottom: 0.5rem;
  padding: 0.375rem 0.5rem;
  background: #f9fafb;
  border-radius: 6px;
}

.tasks-activity-dot {
  position: absolute;
  left: -1.125rem;
  top: 0.625rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.tasks-activity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tasks-activity-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.tasks-activity-badge {
  color: white;
  padding: 0.0625rem 0.375rem;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 500;
}

.tasks-activity-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: #4f46e5;
  text-decoration: none;
}

.tasks-activity-time {
  font-size: 0.65rem;
  color: #9ca3af;
}

.tasks-activity-message {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 0.125rem;
}

.tasks-activity-actor {
  font-weight: 500;
}

/* --- Bulk Action Bar --- */
.tasks-bulk-bar {
  display: none;
  position: sticky;
  top: 58px;
  z-index: 10;
  background: #4f46e5;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tasks-bulk-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tasks-bulk-count {
  font-size: 0.8rem;
  font-weight: 600;
}

.tasks-bulk-btn {
  color: white;
  border: none;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
}

.tasks-bulk-btn--complete { background: #10b981; }
.tasks-bulk-btn--pending  { background: #6b7280; }
.tasks-bulk-btn--depri    { background: #d97706; }

.tasks-bulk-deselect {
  color: rgba(255,255,255,0.8);
  font-size: 0.75rem;
  margin-left: auto;
  text-decoration: none;
}

/* --- Table View --- */
.tasks-table-wrapper {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow-x: auto;
}

.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.tasks-table-th {
  padding: 0.5rem 0.625rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: #6b7280;
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  user-select: none;
}

.tasks-table-th--checkbox {
  width: 36px;
  text-align: center;
}

.tasks-table-th--id { width: 60px; }
.tasks-table-th--urgency { width: 72px; text-align: center; }
.tasks-table-th--importance { width: 72px; text-align: center; }
.tasks-table-th--status { width: 80px; }
.tasks-table-th--stage { width: 140px; }
.tasks-table-th--worker { width: 80px; }
.tasks-table-th--date { width: 100px; }

.tasks-table-sort-link {
  color: #6b7280;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.tasks-table-sort-link:hover {
  color: #374151;
}

.tasks-table-sort-link--active {
  color: #4f46e5;
  font-weight: 700;
}

.tasks-table-row {
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}

.tasks-table-row:hover {
  background: #f9fafb;
}

.tasks-table-row--completed {
  opacity: 0.55;
}

.tasks-table-row--subtask {
  background: #fafbfc;
}

.tasks-table-row--subtask:hover {
  background: #f3f4f6;
}

.tasks-table-td {
  padding: 0.5rem 0.625rem;
  vertical-align: middle;
}

.tasks-table-td--checkbox {
  text-align: center;
}

.tasks-table-td--id {
  color: #9ca3af;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.tasks-table-td--urgency,
.tasks-table-td--importance {
  text-align: center;
}

.tasks-table-td--date {
  color: #9ca3af;
  font-size: 0.75rem;
  white-space: nowrap;
}

.tasks-table-td--subtask-title {
  padding-left: 2rem;
}

.tasks-table-checkbox {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #4f46e5;
}

.tasks-table-check-all {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #4f46e5;
}

.tasks-table-title-link {
  color: #111827;
  text-decoration: none;
  font-weight: 600;
}

.tasks-table-title-link:hover {
  text-decoration: underline;
  color: #4f46e5;
}

.tasks-table-title-link--subtask {
  color: #4f46e5;
  font-weight: 500;
  font-size: 0.8rem;
}

.tasks-table-subtask-count {
  color: #9ca3af;
  font-size: 0.7rem;
  margin-left: 0.375rem;
}

.tasks-table-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
}

.tasks-table-score--high {
  background: #fef2f2;
  color: #dc2626;
}

.tasks-table-score--mid {
  background: #fefce8;
  color: #ca8a04;
}

.tasks-table-score--low {
  background: #f0fdf4;
  color: #16a34a;
}

.tasks-badge {
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}

.tasks-badge--score {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.7rem;
}

.tasks-badge--status {
  color: white;
}

.tasks-badge--stage {
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  font-size: 0.675rem;
}

.tasks-badge--worker {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: white;
  font-size: 0.675rem;
}

.tasks-badge--worker-running { background: #059669; }
.tasks-badge--worker-idle    { background: #d97706; }

.tasks-worker-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.tasks-worker-dot--running {
  background: #6ee7b7;
  animation: worker-pulse 1.5s ease-in-out infinite;
}

.tasks-worker-dot--idle {
  background: #fcd34d;
}


/* --- Empty State --- */
.tasks-empty {
  background: #f9fafb;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  color: #6b7280;
}

.tasks-empty a {
  color: #4f46e5;
}

/* --- Mobile Responsive --- */
@media (max-width: 1024px) {
  .tasks-main-layout {
    grid-template-columns: 1fr;
  }

  .tasks-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 768px) {
  .tasks-container {
    padding: 0 0.375rem;
    margin-top: 0.125rem;
  }

  .tasks-page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.125rem;
    margin-bottom: 0.25rem;
  }

  .tasks-page-header h1 {
    font-size: 1.125rem;
    margin-bottom: 0;
  }

  .tasks-header-subtitle {
    display: none;
  }

  .tasks-header-actions {
    flex-wrap: wrap;
    gap: 0.2rem;
  }

  .tasks-header-actions a,
  .tasks-header-actions .tasks-btn {
    flex: 1;
    text-align: center;
    min-width: 0;
    padding: 0.2rem 0.375rem;
    font-size: 0.7rem;
  }

  .tasks-flash {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
  }

  .tasks-summary {
    flex-direction: column;
    align-items: stretch;
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.25rem;
    gap: 0.25rem;
    border-radius: 6px;
  }

  .tasks-summary-stats {
    gap: 0.25rem;
  }

  .tasks-summary-value {
    font-size: 1rem;
  }

  .tasks-summary-label {
    font-size: 0.6rem;
  }

  .tasks-summary-divider {
    display: none;
  }

  .tasks-summary-workers {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #e5e7eb;
    padding-top: 0.25rem;
  }

  .tasks-filter-bar {
    padding: 0.375rem;
    margin-bottom: 0.375rem;
    border-radius: 6px;
  }

  .tasks-filter-form {
    flex-direction: column;
    gap: 0.25rem;
  }

  .tasks-filter-input,
  .tasks-filter-select {
    width: 100%;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .tasks-main-layout {
    gap: 0.375rem;
  }

  .tasks-table {
    font-size: 0.7rem;
  }

  .tasks-table-th {
    padding: 0.375rem 0.375rem;
    font-size: 0.65rem;
  }

  .tasks-table-td {
    padding: 0.375rem 0.375rem;
  }

  .tasks-table-th--stage,
  .tasks-table-th--worker,
  .tasks-table-th--date {
    display: none;
  }

  .tasks-table-td--stage,
  .tasks-table-td--worker,
  .tasks-table-td--date {
    display: none;
  }

  .tasks-table-title-link {
    font-size: 0.75rem;
  }

  .tasks-table-score {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }

  .tasks-badge {
    padding: 0.0625rem 0.3rem;
    font-size: 0.6rem;
  }

  .tasks-bulk-bar {
    padding: 0.25rem 0.375rem;
    margin-bottom: 0.25rem;
  }

  .tasks-bulk-count {
    font-size: 0.7rem;
  }

  .tasks-bulk-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.65rem;
  }

  .tasks-sidebar-tabs {
    margin-bottom: 0.375rem;
  }

  .tasks-sidebar-tab {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }

  .tasks-sidebar-section {
    margin-bottom: 0.375rem;
  }

  .tasks-sidebar-section-header {
    padding: 0.375rem 0.5rem;
  }

  .tasks-sidebar-section-title {
    font-size: 0.8rem;
  }

  .tasks-sidebar-section-content {
    padding: 0.375rem;
    padding-top: 0;
  }

  .tasks-terminal-pre {
    min-height: 60px;
    max-height: 120px;
    font-size: 0.6rem;
    word-break: break-all;
    padding: 0.375rem;
  }

  .tasks-chat-messages {
    max-height: 180px;
    min-height: 80px;
    padding: 0.375rem;
  }

  .tasks-chat-msg {
    padding: 0.25rem 0.375rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
  }

  .tasks-ai-textarea {
    min-height: 50px;
    padding: 0.375rem;
    font-size: 0.75rem;
  }

  .tasks-ai-description {
    font-size: 0.7rem;
    margin-bottom: 0.25rem;
  }

  .tasks-empty {
    padding: 0.75rem;
    font-size: 0.8rem;
  }

  .tasks-activity-item {
    margin-bottom: 0.25rem;
    padding: 0.2rem 0.3rem;
  }

  .tasks-activity-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .tasks-activity-badge {
    font-size: 0.6rem;
  }

  .tasks-activity-link {
    font-size: 0.7rem;
  }
}

/* === Tasks Show: Mobile reorder (chat directly above terminal) === */
@media (max-width: 768px) {
  .task-show-reorderable {
    display: flex;
    flex-direction: column;
  }

  .task-show-chat { order: 1; }
  .task-show-terminal { order: 2; }
  .task-show-process-logs { order: 3; }
  .task-show-activities { order: 4; }
  .task-show-subtasks { order: 5; }
  .task-show-reorderable > script { order: 6; }

  /* チャットとターミナルを隣接させるためmarginを縮小 */
  .task-show-chat {
    padding: 0.75rem !important;
    margin-bottom: 0.375rem !important;
    border-radius: 6px !important;
  }

  .task-show-terminal {
    padding: 0.75rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 6px !important;
  }

  .task-show-process-logs,
  .task-show-activities,
  .task-show-subtasks {
    padding: 0.75rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: 6px !important;
  }

  /* チャットメッセージ欄の高さを縮小 */
  .task-show-chat #chat-messages {
    max-height: 250px !important;
    padding: 0.5rem !important;
  }

  /* ターミナル出力の高さを縮小 */
  .task-show-terminal .manager-terminal-pre {
    max-height: 300px !important;
    padding: 0.5rem !important;
    font-size: 0.7rem !important;
  }

  /* セクションヘッダーのフォントサイズ縮小 */
  .task-show-reorderable h2 {
    font-size: 1rem !important;
  }

  /* Show画面全体のモバイル余白を縮小 */
  .task-show-container {
    padding: 0 0.375rem !important;
    margin-top: 0.5rem !important;
  }
}

/* --- Chat Image Upload --- */
.tasks-chat-image-btn {
  background: #374151;
  color: #c9d1d9;
  border: 1px solid #555;
  padding: 0.375rem 0.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}

.tasks-chat-image-btn:hover {
  background: #4b5563;
}

.tasks-chat-preview {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  padding: 0.375rem;
  background: #161b22;
  border: 1px solid #333;
  border-radius: 6px;
  margin-bottom: 0.375rem;
}

.tasks-chat-preview-item {
  position: relative;
  width: 56px;
  height: 56px;
}

.tasks-chat-preview-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #444;
}

.tasks-chat-preview-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: none;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tasks-chat-images {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-top: 0.375rem;
}

.tasks-chat-image-link {
  display: block;
}

.tasks-chat-image-thumb {
  max-width: 120px;
  max-height: 90px;
  border-radius: 4px;
  border: 1px solid #444;
  object-fit: cover;
  cursor: pointer;
  transition: opacity 0.15s;
}

.tasks-chat-image-thumb:hover {
  opacity: 0.85;
}

/* --- Activity Log (main content area) --- */
.tasks-activity-log {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-top: 1.25rem;
  overflow: hidden;
}

.tasks-activity-log-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tasks-activity-log-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #374151;
  margin: 0;
}

.tasks-activity-log-count {
  font-weight: 400;
  font-size: 0.8rem;
  color: #9ca3af;
}

.tasks-activity-log-filters {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.tasks-activity-filter-tag {
  font-size: 0.65rem;
  padding: 0.125rem 0.375rem;
  border-radius: 8px;
  text-decoration: none;
  color: #6b7280;
  border: 1px solid #d1d5db;
  transition: background 0.15s, color 0.15s;
}

.tasks-activity-filter-tag:hover {
  background: #f3f4f6;
}

.tasks-activity-filter-tag--active {
  color: white;
}

.tasks-activity-filter-clear {
  font-size: 0.7rem;
  color: #6b7280;
  text-decoration: underline;
  margin-right: 0.25rem;
}

.tasks-activity-log-list {
  max-height: 400px;
  overflow-y: auto;
}

.tasks-activity-log-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  border-bottom: 1px solid #f9fafb;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.tasks-activity-log-item:last-child {
  border-bottom: none;
}

.tasks-activity-log-item:hover {
  background: #f9fafb;
}

.tasks-activity-log-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tasks-activity-log-task-link {
  font-size: 0.75rem;
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.tasks-activity-log-task-link:hover {
  text-decoration: underline;
}

.tasks-activity-log-message {
  font-size: 0.75rem;
  color: #6b7280;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tasks-activity-log-time {
  font-size: 0.65rem;
  color: #9ca3af;
  white-space: nowrap;
  margin-left: auto;
}

.tasks-activity-log-empty {
  color: #9ca3af;
  font-size: 0.8rem;
  text-align: center;
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .tasks-activity-log {
    margin-top: 0.5rem;
  }

  .tasks-activity-log-header {
    padding: 0.5rem 0.625rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .tasks-activity-log-title {
    font-size: 0.85rem;
  }

  .tasks-activity-log-filters {
    display: none;
  }

  .tasks-activity-log-item {
    padding: 0.25rem 0.625rem;
    font-size: 0.7rem;
  }

  .tasks-activity-log-task-link {
    max-width: 150px;
    font-size: 0.65rem;
  }

  .tasks-activity-log-message {
    font-size: 0.65rem;
  }

  .tasks-activity-log-list {
    max-height: 250px;
  }
}
